LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-29-2010, 05:39 AM   #1
harishisnow
LQ Newbie
 
Registered: Nov 2010
Location: bangalore, india
Posts: 17

Rep: Reputation: 0
'fstream' does not name a type


Hello,
I have included fstream in my file (#include <fstream>)
In the file, I have a class declaration and a private variable
static fstream fileStopWatch ;
Then I am getting the error "'fstream' does not name a type"
It was working in gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)
but not working in gcc version 4.4.4 (GCC)

ex:
class Utility
{
..
..
private:
static fstream fileStopWatch ;
..
..
};
Please suggest a solution for the above problem.

Regards,
Harish
 
Old 11-29-2010, 06:56 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
The error means that it cannot find a type named fstream. This is happening because fstream is in the std namespace. Try the following instead:
Code:
class Utility
{
..
..
private:
static std::fstream fileStopWatch ;
..
..
};
However, this change (not polluting the global namespace) happened around the 3.x series of gcc. There are also some minor changes in the requirements on scoping of the standard library as we move towards C++0x.

Last edited by neonsignal; 11-29-2010 at 07:21 AM.
 
Old 11-30-2010, 12:12 AM   #3
harishisnow
LQ Newbie
 
Registered: Nov 2010
Location: bangalore, india
Posts: 17

Original Poster
Rep: Reputation: 0
Smile

Hello,
Thanks a lot for your response.
The change worked.
Regards,
Harish
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fstream troubles Lorian Programming 17 02-19-2009 11:31 AM
fstream to FILE* Jacko123 Programming 2 05-22-2007 12:14 PM
fstream issues :( nathacof Programming 8 05-31-2006 07:28 PM
C++ Fstream trouble mrcheesypants Programming 3 04-07-2006 09:31 PM
c++ fstream:: question javakid Programming 2 01-21-2005 01:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration