# Am I retarded?

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

## 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 on other sites
"log" is declared a function as written. Try this:
    ofstream log;

##### Share on other sites
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 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 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 on other sites
Quote:
 Am I retarded?

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

##### Share on other sites
Quote:
 Original post by NImC:\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 on other sites
Quote:
 Original post by Drew_BentonHave 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 on other sites
Quote:
 Original post by TriencoWell, 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.

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633416
• Total Posts
3011780
• ### Who's Online (See full list)

There are no registered users currently online

×