• Advertisement
Sign in to follow this  

Am I retarded?

This topic is 4257 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

...Or is it my system? I have the following code:
    ofstream log();
    log.open("navalie-log.txt",ios::out);
WHich generates this error:
9 C:\Documents and Settings\Owner\Desktop\clank\clank.cpp request for member `open' in `log', which is of non-class type `std::ofstream ()()' 
is std::ofstream not a class? What does "non class type mean?"

Share this post


Link to post
Share on other sites
Advertisement
But then

8 C:\Documents and Settings\Owner\Desktop\clank\clank.cpp aggregate `std::ofstream log' has incomplete type and cannot be defined


EDIT
and if I write

ofstream log("navalie-log.txt",ios::out);

then I get

8 C:\Documents and Settings\Owner\Desktop\clank\clank.cpp variable `std::ofstream log' has initializer but incomplete type

Share this post


Link to post
Share on other sites
get rid of the () in "ofstream log();"
should be just "ofstream log;"

EDIT:
ha ha beaten
did you #include<fstream> and not just #include<iostream>?

Share this post


Link to post
Share on other sites
Have you tried using a different variable name? I've had problems in the past where I had a name collision with the standard C++ library (something I didn't even know) and only way around it was to change the variable name.

Share this post


Link to post
Share on other sites
Quote:
Am I retarded?

yes, though u can put a positive spin on it by calling yourself 'special needs'

Share this post


Link to post
Share on other sites
Quote:
Original post by NIm
C:\Documents and Settings\Owner\Desktop\clank\clank.cpp aggregate `std::ofstream log' has incomplete type and cannot be defined


Translation: `all I see is "class ofstream;", I don't have a body for it which lists all the member functions and variables - it's incomplete!`.

#include <fstream> should set you straight.

Share this post


Link to post
Share on other sites
Quote:
Original post by Drew_Benton
Have you tried using a different variable name? I've had problems in the past where I had a name collision with the standard C++ library (something I didn't even know) and only way around it was to change the variable name.


Well, especially if you include the math header, you MIGHT just have a little conflict with a certain logarithm. And hey, namespaces are for sissies *cough*

Share this post


Link to post
Share on other sites
Quote:
Original post by Trienco
Well, especially if you include the math header, you MIGHT just have a little conflict with a certain logarithm.


Even if you don't include the math header you might get a conflict, any SC++L header is allowed to include any other SC++L header. This is the reason why people says using namespace std is a bad thing.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement