...

View Full Version : expected unqualified error problem



dsylebee
07-02-2009, 06:52 AM
C:\Documents and Settings\Administrator\Desktop\cpp\tryingClasses\main.cpp|5|error: expected unqualified-id before "using"|
C:\Documents and Settings\Administrator\Desktop\cpp\tryingClasses\main.cpp||In function `int main()':|
C:\Documents and Settings\Administrator\Desktop\cpp\tryingClasses\main.cpp|14|error: `cout' was not declared in this scope|
C:\Documents and Settings\Administrator\Desktop\cpp\tryingClasses\main.cpp|14|error: `endl' was not declared in this scope|
||=== Build finished: 3 errors, 0 warnings ===|




#include <iostream>
#include <string>
#include "person.h"

using namespace std;



int main()
{
person david("david");
person brhams("bhrams", 34);

cout << "name: " << brhams.getName() << " age: " << brhams.getAge() << endl << endl;

david.setAge(20);
david.setName("David Lebee");

cout << "fullname: " << david.getName() << " age: " << david.getAge() << endl << endl;

return 0;
}

oracleguy
07-03-2009, 12:25 AM
The problem is in person.h, I bet you forgot the semicolon off the end of your class declaration.

BrickInTheWall
07-03-2009, 12:42 AM
The problem is in person.h, I bet you forgot the semicolon off the end of your class declaration.
I was just about to say that :D...this happens to me a lot and being a beginner I would always look for the error for several minutes...



class ClassName{
// Members, Methods, Constructor, Destructor etc.
}; <------

saadhamza
07-03-2009, 03:03 AM
wait, i want to try this out, so what are we supposed to change XD

BrickInTheWall
07-03-2009, 02:13 PM
wait, i want to try this out, so what are we supposed to change XD
you should check your class declaration and see if you forgot to add the semicolon at the end of it.
from dsylebee's code you can see what methods the class contains...ones to set the name, one to display the name, one to set the age and one to display the age...maybe there are more methods that aren't used right now but just from the code in his main function you can see the basic way his class works. Since he is using methods to change class members you can assume these to be private...otherwise he could just use brahms.age (assuming the age variable member is called "age") to retrieve it rather than using a method to do so.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum