C++ :: Variable Or Field Entered Void

Jan 16, 2012

I am experiencing some errors with my first c++ program. im getting some compilation errors that i cannot figure out.

In file included from w2.cpp:7:
Fraction.h:17: error: variable or field 'enter' declared void
Fraction.h:17: error: expected primary-expression before 'struct'
Fraction.h:18: error: variable or field 'display' declared void
and so on ..........

Code:
#include "fraction.h"
//using namespace std;
/*
int main() {
struct Fraction fraction;
cout << "Fraction Simplifier" << endl;
cout << "===================" << endl;
enter(&fraction);

[Code] .....

View 1 Replies


ADVERTISEMENT

C :: Variable Or Field Declared Void And Other Errors

Mar 29, 2014

I'm creating a payroll program and here is my code

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define REPORTHEADING1 " Employee Pay Hours Gross Tax Net
"
#define REPORTHEADING2 " Name Rate Worked Pay Due Pay
}

[code]....

The errors I get are: variable or field PrintSummaryReport declared void in function voidPrintSummaryReport... cannot convert FILE to const car for argument to int printf(const char*...) which is for the following lines

Code:

printf(reportFile,REPORTLINEFORMAT1,fullName,payrate,regHours,gross,fedtax,
ssitax,netpay);
printf(reportFile,REPORTLINEFORMAT2,ovtHours,statetax,deferred);

View 7 Replies View Related

C++ :: Error - Variable Or Field Declared Void

Sep 17, 2014

Why I am getting this error

error: variable or field createBinaryFile declared void

void createBinaryFile(std::fstream&, std::ifstream&);

View 2 Replies View Related

C/C++ :: Getting Variable Or Field Declared Void And Other Errors

Mar 28, 2014

I'm creating a payroll program and here is my code

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define REPORTHEADING1 " Employee Pay Hours Gross Tax Net
"
#define REPORTHEADING2 " Name Rate Worked Pay Due Pay

[code]....

View 14 Replies View Related

C/C++ :: Error Variable Or Field View Declared Void

Oct 10, 2014

On running the following codes I'm getting these errors. I'm using Code Blocks 13.12

void view(string); //error: variable or field 'view' declared void & error: 'string' was not declared in this scope
void customer()
{
char ch;

[Code]....

View 4 Replies View Related

C++ :: Virtual Can Only Exist In Non-static Member Function - Field Has Incomplete Type Void

Dec 5, 2014

I'm writing a class "Property" for a program that manages different types of properties. This is my .h for y base class. I was trying to write a virtual void function to convert different children classes to strings that can be displayed, but Xcode is freaking out.

I had it as:

virtual void toString()= 0;

and it gave me an error message: "Virtual can only exist in non-static member functions" and "field has incomplete type 'void'"

I changed it to:

virtual string toString() = 0;

and the error message didn't change.

Is this an issue with Xcode or did I do something wrong? Even after changing it to string it told me that it "has incomplete type 'void'"....

View 1 Replies View Related

C++ :: How To Declare Variable For All Void

Jul 25, 2013

How to declare variable for all void() as I have another void s in my C++ program. I want to have a variable that can use for all the void and not only in a simple void.Is it possible?

View 17 Replies View Related

C# :: Field Initializer Cannot Reference The Non-static Field / Public Var

Apr 12, 2015

So I have this class

class DataBase
{
// Change the connection path here to your own version of the database
public SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;AttachDbFilename=|DataDirectory|UberDatabase.mdf;Integrated Security=True;");
public DataBase()
{
}
}

And in the same namespace as this class I have a form that calls it like so:

DataBase dBase = new DataBase();
SqlCommand trythis = new SqlCommand("Register", dBase.con);

However, I'm getting the field initializer error on dBase.con. I'm not sure why, but when I call the database from another file (program.cs) it works fine this way.

View 8 Replies View Related

C++ :: Program To Display Error Message If Variable Entered Not An Integer

Nov 8, 2013

I need to have a program display an error message if the variable entered isn't an integer but then I want it to cin again. I have this but it doesn't work:

cout << "Enter an Integer: " ;
for (;;) {
cin >> var;
if (!cin) {

[Code] ....

I am not sure how to do what I want and this doesn't work, it just repeats That wasn't an int.. over and over again.

View 8 Replies View Related

C++ :: Add Variable Address To Void Pointer Inside Of Class?

Dec 1, 2013

How can I add the variable adress to a void pointer inside of a class?

class variant2 {
private:
void *Vvariant=NULL;
public:
template<typename b>
variant & operator = (b *adress)

[Code] ....

if possible i want avoid the '&' when i assign the variable address.(variant2 f=varname;//like you see i don't use the '&')
for the moment i just need put the address to Variant pointer. but i receive several errors .

View 4 Replies View Related

C++ :: If Statement Error - Match Text Variable That User Has Entered With Another Got From Array

Dec 3, 2014

I have an if statement that should either match a text variable that the user has entered and a another text variable that has been got from an array but they won't match even if they are the same,Im at a lost with it.

void displayQuestion(int noQuestion, string questionArray[], string answerarray[], string answer, double scorearray, double finalscore){

cout << questionArray[noQuestion] << endl;
cout << "enter an answer " << endl;
cin >> answer;

[Code] ....

View 1 Replies View Related

C/C++ :: Find Max Number Entered By User And Terminate When Negative Number Entered

Jul 15, 2014

I am trying to find the max number entered by the user, and it should terminate when a negative number is entered. For my code, it will just end when the user inputs a lower number than the previous. i.e.- 10 20 15 "The highest number is 20" when it should be "10 20 5 40 15 -1" "The highest number is 40". No arrays or do/while loops either.

#include <iostream>
using namespace std;
int Max(int x);
int main() {
int x;

[Code] ....

View 9 Replies View Related

C :: Sorting Has To Be Based On Int Field

Feb 16, 2013

I have a file which has records with 2 fields--one int and one float..what is the best way to sort it?

The sorting has to be based on the int field(the first field) (each time the program runs the file might end up with some hundreds of records).

View 13 Replies View Related

C :: Structure Field Value Is 0 When It Shouldn't

Sep 11, 2014

I'm trying to write a simple program that extract the FAT information from a FAT32 virtual Hard Disk.I have the following structures regarding the FAT format:

Code:

//BOOT RECORD
typedef struct NF_BOOT_RECORD
{
unsigned char BS_jumpBoot[3]; //EB 58 90 = JUMP 58 NOP (Jumps to boot code). Also E9 is acceptable.
unsigned char BS_OEMName[8]; //Either MSWIN4.1 or mkdosfs
unsigned short BS_BytesPerSec; //Little endian. The size of a sector. 128,256,512,1024...
unsigned char BS_SecPerClus; //The number of sectors per cluster (1 CLUSTER = BPS*SPC BYTES)
unsigned short BS_RsvdSecCnt; //The boot sectors (this) are included. That makes at least 1.
}

[code]...

Everything seems to work fine. Mostly. The only problem, is that the program gives me the following output:BS_NumFATs shouldn't be 0. In fact, I've checked inside the structure memory, and the information seems correct. BS_NumFATs is 0x02, not 0x00 (It's the byte at offset 0x10, starting at 0x00).

I've checked the order of the structure fields, and their types, comparing them to the FAT specification given by Microsoft (File fatgen103.pdf), and it seems fine, unless I'm missing something. So I don't know why it gives 0 instead of 2, if I'm missing something.It's a Win32 program compiled with GCC version 4.4.0

View 3 Replies View Related

C++ :: Rotating Pixel Field

Apr 21, 2014

I wrote a script that generates n random pixel positions and draws them to the screen. Works well. Now i tried to rotate them. Rotating does work too. But it does not work as i planned it.

paramters 'angle' and 'timestep' work somehow, but not as they should do. the function 'move' is supposed to rotate the pixelfield 'angle' degrees in a given direction, addicted to the 'timestep' parameter. 'timestep' is needed time for drawing in one single game loop.

angle_step = timestep * angle
// x
ppdPoint[i]->x =
pRotationPoint->x + cos(angel_step) * (ppdPoint[i]->x - pRotationPoint->x) - sin(angel_step) * (ppdPoint[i]->y - pRotationPoint->y);
// y
ppdPoint[i]->y =
pRotationPoint->y + sin(angel_step) * (ppdPoint[i]->x - pRotationPoint->x) + cos(angel_step) * (ppdPoint[i]->y - pRotationPoint->y);

rotation point is the middle of the screen. when i set angle to 10 it should rotate 10 degrees / second. Instead it's rotating very very fast and all stars are moving nearer to the center of the screen, so after x rounds there is just 1 pixel left in the middle of the screen. there is a kind of gravition.I'm working with SDL2. What I did find out:

FPS is <= 60, 'cause of the 'SDL_RENDERER_PRESENTVSYNC' flag. When i skip that flag, for any reason the 'gravition' would take more time. FPS is <= 1400 then, 'though i got a natural game loop (i hope):

while(pBuild->getExecuteFlag())
{
pBuild->draw();
pBuild->update(time_dif, pTimeWindow->TimeStampB);
time_dif = (pTimeWindow->TimeStampB - pTimeWindow->TimeStampA);
time_dif *= 0.001;
pTimeWindow->TimeStampA = pTimeWindow->TimeStampB;
pTimeWindow->TimeStampB = SDL_GetTicks();

pBuild->count_fps(pTimeWindow->TimeStampB);
}

So maybe (timestep * angle) isn't the right way?

View 13 Replies View Related

C++ :: How To Output One Particular Field In A Form

Aug 8, 2014

I need writing a program in c++ that will get the input of 50 different users for the following the fields (surname, other names, sex, status, date of birth) and after entering the data for these 50 users, it will then output only the list of all FEMALE users who were registered...

#include <iostream>
#include <string>
using namespace std;
int main () {
string surname, other_names1, other_names2, status, sex, dob;

[Code] ....

I don't really know what to do next - all my attempts have not really given me the result I want.

View 19 Replies View Related

C# :: Using DateTime Field From SQL Database

Oct 30, 2014

I have a DateTime field on a database it looks like this :

2014-10-21 14:34:37.697

I want to use it, as is, in an UPDATE statement something like:

UPDATE PayrollRuns SET IsProcessed = 'True' WHERE Date_Time_Triggered = '2014-10-21 14:34:37.697'

I must have the exact date & time as that uniquely identifies the record.

The problem I'm having is getting it off the database and into an C# variable without it being changed.

I can get it into a string but it changes it becomes:

21/10/2014 14:34:37

I've got it in an object. I've tried:

string date_Time_Triggered = databasesRow["Date_Time_Triggered"].ToString();
//
//and
//
var date_Time_Triggered = databasesRow["Date_Time_Triggered"];

[Code] ....

View 3 Replies View Related

C/C++ :: How To Access Field Of A Class By Name

May 2, 2012

class myCls{
int x;
};

and then I create:

myCls c1;

and now:

is there way that I go like: cout << c1;
not overloading << operator;
and it shows me a value of c1.x?
just wanna replace c1 with that value;
I need sth similar to indexer from c#.

View 1 Replies View Related

C++ :: How To Exchange Strings In Field

Sep 29, 2013

I need exchange strings in field, but how to do that. For example:

{"Hi", "Hello", "Goodbye", "Morning"};
to
{"Hello", "Hi", "Goodbye", "Morning"};

I tried this, but it isn't working:

Code:
for(unsigned int k=0; k<slova[i].size();k++){
t = slova[i][k];
slova[i][k] = slova[i+1][k];
slova[i+1][k] = t;
}

View 7 Replies View Related

C++ :: Pre-Compile Check If Field Does Already Exists

Nov 27, 2014

I have a dynamic storage class based on a vector. The elements of this class shall be addressable via a string.

I have something like the following:

StorageClass* test = new StorageClass();
while(notEnd) {
test->setValue("name3", 3);
test->setValue("name2", 4);

[Code] ....

The Storage class is implement with a vector having to attributes per entry, the first one is name the second one is value. If the setValue function is called, Igo through the whole vector to find the correct item via the name and than i set the new value.

At the end of the loop i want to write out the data into a comma separated value file (*.csv). This shall be done generic by the writeLineToFile() function of the StorageClass.

As a want the columns in csv file to be sorted in a specific way a thought about a preInitalisation routine at the beginning of the program which builds a the vector with all possible entries as something like this in order to define a specific output order.

test->assign("name1");
test->assign("name2");
test->assign("name3");

So my outputfile should look like this:

name1;name2;name3;
5;4;3;

I now have 2 places in the code where i write down the "fieldnames".

I was wondering if there is a possibility to check if the fields called by the setValue function were first aranged in the vector by the assigned() function before or bettwer while compiling the programm.

I thought about MAKROS with #define XYZ and #ifndef XYZ #error to do though, but currently i reached a dead end and find no solution for my problem.

View 4 Replies View Related

C++ :: Input Date Field In A Comment

Mar 11, 2014

I am building a template for CodeBlocks, which pre-write some includes, the main skull and a header.

This header looks like that :
/**
* @Author Me
* @Description Brief description
* @Date ??
*/

I would like to put the current Date, just after the line @Date, is-it possible ? And if yes, it-is possible to put a field @FileName which copy the filename into the comment ?

View 2 Replies View Related

C++ :: Use Object In Header File Field

Mar 26, 2013

I need to use an instance of an object in a header file. The object requires a lot of pre-computation to be created.

I want to assign it to a "static const *NAMEobject*" field in the .h file, once it has been created. I assume that it is better to create it in another file and somehow pass it into the .h file.

View 14 Replies View Related

C++ :: How To Produce Password Field With Asterisk

Sep 2, 2014

void Log_In() {
system("cls");
gotoxy(30, 30);
time_t now;
time(&now);

[Code] .....

How to produce a password field with asterisk ****** .....

View 1 Replies View Related

C# :: Why Can't A Constant Field Be Of Non-built-in Struct Type

Dec 9, 2011

Code:

class T
{
enum E { }
struct S { }
interface I { }
delegate void D();
class C { }
}

[code]....

All of the above are possible except the constant field of a type that is a struct. I can see why the non-string reference types would default to the only literal expression they can represent - null - and if I'm not mistaken the default value of a struct is an instance of the struct with all its fields set to their default value, but why is it that a const struct field is not possible? is there a reason why or is it just the way c# was written? oh and by the way, what's the idea of allowing enum types to have a default constructor?

View 4 Replies View Related

C++ :: Initializing Static Field As A Template Object

Aug 26, 2014

I need a static hash table to keep track of all objects of a particular type that are instantiated in a Qt application but I have never used a template class as a static member object before and I can't seem to figure out how to initialize it. QHash is the hash table class that follows the template convetion:

template<class key, class data>

QString is probably self explanatory.

Example Header:

class MyClass {
...
private:
static QHash<QString, MyClass*> instanceTable;
}

Here is my source that doesn't compile.

Example Source

#include header.h
// using default constructor for table...
QHash<QString key, MyClass* instance> MyClass::instanceTable(); // gives Error below.
// Error in above line is "Declaration is incompatible with QHash<QString, Myclass*>"

I have tried doing it a number of different ways and none of them work. How do you initialize a static template object?

View 2 Replies View Related

C++ :: Control Ofstream Output Field Width?

Apr 25, 2013

I have to output a series of data, I have to control the width of parts of my data. like following:

double a[] = {1.0, 2.0, 3.0};
double b[] = {1.5, 2.5, 3.5};
ofsteam myfile("result.txt");
for(int i=0; i<3; i++) {
myfile.width(5);
myfile << i+1 << " : " << a[i] << " - " << b[i] << end;
}

I only want to fix the width of a[i], b[i], but let the rest to be output normally.

how I can make it?

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved