Results 1 to 5 of 5
|
Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
-
09-27-2010 #1
- Join Date
- Aug 2010
- Posts
- 32
Confused on object oriented programing (C++)
class her {
public:
cout << "hi";
};
I get an error at the cout saying "This declaration has no storage class or type specifier"
Now it could be a syntax error for all I know. I knew a little bit of java and got classes working in it so I don't see what's wrong. Just for reference here is my main:
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
using namespace std;
void main()
{
her obj;
her();
system ("pause");
}
If Everything I did is a total mess, I don't expect you guys to teach me, but if you could tell me a great website, or better yet, recommend a book for C++ that would be great.
-
09-27-2010 #2
you can't put code like that into the declaration of a class, you would have to define a function and put it in the body of the function
cplusplus.com - The C++ Resources Network
-
09-27-2010 #3
- Join Date
- Apr 2007
- Posts
- 119
The format of the class is wrong. I have always used C++:The Complete Reference. I am sure there are a bunch of books that are just as good, not to mention other free web sites.
-
09-27-2010 #4
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
- Posts
- 14,038
As a C++ newbie, you might want to get a copy of Deitel & Deitel "C++ How To Program" published by Prentice-Hall. It also contains an intro to object-oriented design with UML. In any case, it is a decent introductory book to the subject.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
-
09-27-2010 #5
- Join Date
- Aug 2010
- Posts
- 32
OOP as a whole concept seems to baffle me for some reason though. It did the same thing in Java. I'll check out those sites and books though, thanks for the help guys, hope I figure this out soon.
If I don't though I do suppose I'll have an actual teacher teaching it in college but I'm no very patient :X