LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 08-26-2007, 04:02 AM   #1
kpachopoulos
Member
 
Registered: Feb 2004
Location: Athens, Greece
Distribution: Gentoo,FreeBSD, Debian
Posts: 704

Rep: Reputation: 30
c++: "expected unqualified-id" newbie errors


This is FinancialProductsManager.cc:

Code:
#include "FinancialProductsManager.h"
#include <iostream>
#include <string>

using namespace std;

FinancialProductsManager::bool insertProduct(string fproduct, double value)
{
    
}

FinancialProductsManager::bool removeProduct(string fproduct)
{
    
}

int main(int argc, const char* argv[]) 
{    
    //cout << "testing the FinancialProductManager" << endl << "---------------------------------------------------";
    
}
and this is FinancialProductsManager.h:
Code:
#ifndef _FinancialProductsManager_H
#define	_FinancialProductsManager_H   

#include <hash_map.h>
#include <string>

using namespace std;


class FinancialProductsManager
{
    
    private:
        hash_map<string, int>  _financialProducts;
        
        
    public:
        bool insertProduct(string fproduct, double value);
        bool removeProduct(string fproduct);
}

#endif
When compiling with g++, i get
Code:
Running "rm -rf build/Debug/GNU-Generic/FinancialProductsManager.o" in /shared/kostas/10sem/programming/c++/arbigames


Clean successful. Exit value 0.

Running "make -f nbproject/Makefile-Debug.mk build/Debug/GNU-Generic/FinancialProductsManager.o" in /shared/kostas/10sem/programming/c++/arbigames

mkdir -p build/Debug/GNU-Generic
g++    -c -g -o build/Debug/GNU-Generic/FinancialProductsManager.o FinancialProductsManager.cc
In file included from /usr/include/c++/4.1.3/backward/hash_map.h:59,
                 from FinancialProductsManager.h:4,
                 from FinancialProductsManager.cc:1:
/usr/include/c++/4.1.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
In file included from FinancialProductsManager.cc:1:
FinancialProductsManager.h:22:7: warning: no newline at end of file
FinancialProductsManager.cc:5: error: expected unqualified-id before ‘using’
FinancialProductsManager.cc:7: error: expected unqualified-id before ‘bool’
FinancialProductsManager.cc:12: error: expected unqualified-id before ‘bool’
make: *** [build/Debug/GNU-Generic/FinancialProductsManager.o] Error 1

Build failed. Exit value 2.
What's the problem?
 
Old 08-26-2007, 04:16 AM   #2
cupubboy
Member
 
Registered: May 2003
Location: Bucharest,Romania
Distribution: Fedora Core 7
Posts: 109

Rep: Reputation: 15
There are a few errors, I might miss some because I just woke up.

So let's see

First .. in your .h file you're missing a ';' (semicolon) after the class declaration (e.g.: class X { .... }; )

Also the way you define your methods is wrong, the right way is:

return_value ClassName::methodname(params) {}

so where you have
Code:
FinancialProductsManager::bool insertProduct(string fproduct, double value)
{
    
}
you should change to:
Code:
bool FinancialProductsManager::insertProduct(string fproduct, double value)
{
}
The same goes for FinancialProductsManager::removeProduct

On another note if you do "using namespace std" in the header file ... you don't need to do it also in the .cc files that include it

Hope this helps ...
Cheers!
 
  


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
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 04:08 PM
"NIM thread blocked" & "Deadman Switch (DMS) close to trigger" errors sosborne Linux - Networking 1 06-28-2006 02:07 PM
expected unqualified id Shwetha GS Linux - Software 0 10-21-2005 09:42 AM
FC4 install errors, "diabling IRQ #10" "nobody cares" error message??? A6Quattro Fedora 6 07-20-2005 12:49 PM


All times are GMT -5. The time now is 06:55 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration