LinuxQuestions.org
Visit Jeremy's Blog.
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 02-04-2010, 11:40 AM   #1
gregarion
Member
 
Registered: Jan 2010
Posts: 69

Rep: Reputation: 15
Non type class


Hey guys basically, im trying to save a value in a member object in c ++.


Code:
class readNasdaq
{
    public:
        void Nasdaq(fstream&) ;
        string value ;
    private :
};
This is in my cpp file

string NasdaqValue = line.substr( LocationNasdaqValue , LengthOfNasdaqValue ) ;

Code:
   cout << "  " << endl ;
cout << "The Value Index of Nasdaq is " << NasdaqValue << endl ;

 value = NasdaqValue ;
Am i right to say that now value can be called to be used at other places by

readNasdaq.w();
w.value();

But for some reason, i keep getting an error message saying...

Code:
financetest.cpp:28: error: request for member ‘Nasdaq’ in ‘w’, which is of non-class type ‘readNasdaq ()()'
why is that? and how do i solve this problem?
 
Old 02-04-2010, 01:54 PM   #2
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
Can you post more of your source code (if you want) to allow tracing the error?

Code:
readNasdaq.w();
w.value();
Why is there a dot between the readNasdaq and the w? The class readNasdaq does not contain a member "w".

You cannot call "value" in an object of class "readNasdaq", because class std::string does not implement the operator().

Posting more source code can really help. Especially post line 28, where the error resides.
 
Old 02-04-2010, 03:16 PM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by gregarion View Post
This is in my cpp file
...
value = NasdaqValue ;
But where in your cpp? I expect you intend value to be that member of an object of type readNasdaq, but that line would only make sense in a member function of readNasdaq, which you don't seem to have. Also you don't seem to have the object either.

Quote:
Am i right to say that now value can be called to be used at other places by

readNasdaq.w();
w.value();
I think I'm guessing right that your intent for
readNasdaq.w();
is to define w as an object of type readNasdaq using the default constructor. The correct syntax for that would be:

readNasdaq w;

Your intent for w.value() is to access the value member of w? The correct syntax for that would be: w.value

But remember value is a member of each object of type readNasdaq, so you can't communicate a value by setting it in one object and accessing it in another.

If you want one value for all readNasdaq, make it a static class member, not an ordinary class member.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
c++ : stupid problem (class with no type) Shautieh Programming 27 05-21-2008 03:09 AM
Identify class type Ephracis Programming 1 05-05-2007 09:03 AM
Does derivated class inherit base class destructor (constructor)? kornerr Programming 2 08-23-2006 08:05 AM
Which C++ editor in Linux has the class view/class browser feature imaginationworks Programming 7 05-21-2006 11:09 PM
c++ list class, type of node? exodist Programming 2 05-20-2004 06:27 PM

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

All times are GMT -5. The time now is 01:53 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