| | |
compiling problems
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Hello.I am having some problems with my vc++6 compiler.Here is the code:
here are the compiling errors,I'm sure it's about calling functions from a cout statement..the cout statements are directly from the book the problem is with the compiler:
________________________________
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2146: syntax error : missing ';' before identifier 'years'
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2017: illegal escape sequence
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2065: 'years' : undeclared identifier
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2146: syntax error : missing ';' before identifier 'old'
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2001: newline in constant
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2065: 'old' : undeclared identifier
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2146: syntax error : missing ';' before identifier 'n'
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2065: 'n' : undeclared identifier
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2143: syntax error : missing ';' before 'string'
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(37) : error C2143: syntax error : missing ';' before 'delete'
Error executing cl.exe.
memdthp.obj - 10 error(s), 0 warning(s)
tia i'm a n00b
C++ Syntax (Toggle Plain Text)
#include <iostream.h> class SimpleCat { public: SimpleCat() { itsAge = 2; } // if I put the definition of the function into the daclaration,that becomes an "inline" function ~SimpleCat() { } // class destructor int GetAge() const { return itsAge;} void SetAge ( int age ) { itsAge = age;} private: int itsAge; }; // class declaration ends int main () { cout << " generally,to access data members and functions,\n"; cout << " we use the dot (.) operator...\n"; cout << "but here while accessing the Cat object on the free...\n"; cout << " store,I must dereference(indirectly access from the pointer with * symbol) the pointer and call the dot operator on the object pointed to by the pointer\n"; cout << " to access the GetAge member function,I will write (*pRags).GetAge();\n"; cout << " The format is like this: (*nameOfThePointer).nameOfTheFunctionToBeAccessed();\n"; cout << " But,in c++,the operator needed is (->) or ( dash,greater-than)\n"; SimpleCat * Frisky = new SimpleCat; // creating simplecat object on the freestore or heap cout << " Frisky is" << Frisky->GetAge() << "years old\n"; Frisky->SetAge(5); cout << " Frisky is << Frisky->GetAge() << " years old\n"; delete Frisky ; return 0; }
here are the compiling errors,I'm sure it's about calling functions from a cout statement..the cout statements are directly from the book the problem is with the compiler:
________________________________
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2146: syntax error : missing ';' before identifier 'years'
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2017: illegal escape sequence
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2065: 'years' : undeclared identifier
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2146: syntax error : missing ';' before identifier 'old'
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2001: newline in constant
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2065: 'old' : undeclared identifier
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2146: syntax error : missing ';' before identifier 'n'
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2065: 'n' : undeclared identifier
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(36) : error C2143: syntax error : missing ';' before 'string'
D:\ADOBE\VC++6PROJECTS\accessingmemberdataonheap\memdthp.cpp(37) : error C2143: syntax error : missing ';' before 'delete'
Error executing cl.exe.
memdthp.obj - 10 error(s), 0 warning(s)
tia i'm a n00b
Forum bully
![]() |
Similar Threads
- HELP! C++ DirectX programming: Win32 application compiling problems with Platform SDK (C++)
- Help with Classes !!! (Homework) (C++)
- Compiling Problems code snippets (C#)
- Compiling Problems (C++)
Other Threads in the C++ Forum
- Previous Thread: problem splitting c++ program
- Next Thread: The difference between functions and templates?
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game getline google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





