[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Visual C++ Dilemna

Posted on 2000-01-04
6
Medium Priority
?
327 Views
Last Modified: 2013-12-14
I am trying to create a simple class in VC++ 6.0, professional edition.  The following is the class definition:

#if !defined(AFX_QUERY2_H__0A2EA640_C2A8_11D3_AC4E_0004AC3504ED__INCLUDED_)
#define AFX_QUERY2_H__0A2EA640_C2A8_11D3_AC4E_0004AC3504ED__INCLUDED_

#include <string>
#include <iostream>
#include <vector>

class Query2  
{
public:
      Query2(){};
      Query2(string s){};      
      virtual ~Query2(){};
};

#endif

I am getting the following two errors on the second constructor (and on any other constructor that I add, manually or using the built in "Add Member Function" tool):

c:\kbs code\kbs general\kbs_sqlquery1\query2.h(18) : error C2629: unexpected 'class Query2 ('
c:\kbs code\kbs general\kbs_sqlquery1\query2.h(18) : error C2334: unexpected token(s) preceding '{'; skipping apparent
function body

Any thoughts as to what is causing this problem?  Is it syntax or project settings?

Thanks.
0
Comment
Question by:Laminamia063099
  • 2
  • 2
  • 2
6 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 2323556
It should be:

class Query2  
{
public:
Query2();
Query2(string s);
virtual ~Query2();
};


Then in your Query2.cpp file:

Quert2::Query2()
{
etc.
}

Query2::Query2(string s)
{
etc.
}

Query2::~Query2()
{
etc.
}
0
 
LVL 2

Expert Comment

by:arikka
ID: 2323580
Add  the next line after include block
using namespace std;

So it must be:

#include <string>
#include <iostream>
#include <vector>

using namespace std;


class Query2  
{
public:
Query2(){};
Query2(string s){};
virtual ~Query2(){};
};


0
 
LVL 32

Expert Comment

by:jhance
ID: 2323586
After looking at your code some more, I take my answer back.  There is nothing wrong with:

class Query2  
{
public:
Query2(){};
Query2(string s){};
virtual ~Query2(){};
};


as you have it posted here EXCEPT the line:

Query2(string s){};




0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 3

Author Comment

by:Laminamia063099
ID: 2323609
I see that you've taken back your first answer, jhance, and I thank you for your comments.  However, what do you mean by your comment:
     
     "EXCEPT the line:

                             Query2(string s){};
     ".

Arikka, I will try your suggestion.  I came across the same thought myself, and if it works, I'll tell you to submit an answer.

0
 
LVL 2

Accepted Solution

by:
arikka earned 300 total points
ID: 2323619
I am trying again. It works I already
chaecked it...

Add  the next line after include block
using namespace std;

So it must be:

#include <string>
#include <iostream>
#include <vector>

using namespace std;


class Query2    
{
public:
Query2(){};
Query2(string s){};
virtual ~Query2(){};
};

0
 
LVL 3

Author Comment

by:Laminamia063099
ID: 2326470
Thanks, I'll try it out and grade the answer soon :)

Laminamia
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question