473,385 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Debugging error c2059

I am adding to a large code base, and there is far too much code to
paste it in its entirety. Here is some code that I added:

struct MyStruct
{
MyStruct(const std::string& SomeString, const std::string&
AnotherString)
{

}

};

MyStruct("SomeWord", "AnotherWord");
Of course, the above code is not particularly useful. I was following
the technique of making it as simple as possible to try and see what
was triggering the error.

The compiler complains about MyStruct("SomeWord", "AnotherWord");
Referring to the line number where the above line occurs, it says
error C2059: syntax error : 'string'
Can anyone explain the probable cause of the error?

Thank you all very much for your help.

Paul Epstein
Mar 3 '08 #1
4 5534
pa**********@att.net wrote:
I am adding to a large code base, and there is far too much code to
paste it in its entirety. Here is some code that I added:

struct MyStruct
{
MyStruct(const std::string& SomeString, const std::string&
AnotherString)
{

}

};

MyStruct("SomeWord", "AnotherWord");
Of course, the above code is not particularly useful. I was following
the technique of making it as simple as possible to try and see what
was triggering the error.

The compiler complains about MyStruct("SomeWord", "AnotherWord");
Referring to the line number where the above line occurs, it says
error C2059: syntax error : 'string'
Can anyone explain the probable cause of the error?

Thank you all very much for your help.
Yes. You didn't include <string>
Correct code:

#include <string>
struct MyStruct
{
MyStruct(const std::string& SomeString, const std::string&
AnotherString)
{

}

};

MyStruct("SomeWord", "AnotherWord");
Mar 3 '08 #2
On Mar 3, 12:10*pm, red floyd <no.s...@here.dudewrote:
pauldepst...@att.net wrote:
I am adding to a large code base, and *there is far too much code to
paste it in its entirety. *Here is some code that I added:
struct MyStruct
{
* *MyStruct(const std::string& SomeString, const std::string&
AnotherString)
* *{
* *}
};
MyStruct("SomeWord", "AnotherWord");
Of course, the above code is not particularly useful. *I was following
the technique of making it as simple as possible to try and see what
was triggering the error.
The compiler complains about MyStruct("SomeWord", "AnotherWord");
Referring to the line number where the above line occurs, it says
error C2059: syntax error : 'string'
Can anyone explain the probable cause of the error?
Thank you all very much for your help.

Yes. *You didn't include <string>

Correct code:

#include <string>
struct MyStruct
{
* * MyStruct(const std::string& SomeString, const std::string&
AnotherString)
* * {

* * }

};

MyStruct("SomeWord", "AnotherWord");- Hide quoted text -

- Show quoted text -
Good guess but in fact I did use #include <string>
Thanks a lot for trying to help though.

Any more guesses?

Paul Epstein
Mar 3 '08 #3
On Mar 3, 12:10*pm, red floyd <no.s...@here.dudewrote:
pauldepst...@att.net wrote:
I am adding to a large code base, and *there is far too much code to
paste it in its entirety. *Here is some code that I added:
struct MyStruct
{
* *MyStruct(const std::string& SomeString, const std::string&
AnotherString)
* *{
* *}
};
MyStruct("SomeWord", "AnotherWord");
Of course, the above code is not particularly useful. *I was following
the technique of making it as simple as possible to try and see what
was triggering the error.
The compiler complains about MyStruct("SomeWord", "AnotherWord");
Referring to the line number where the above line occurs, it says
error C2059: syntax error : 'string'
Can anyone explain the probable cause of the error?
Thank you all very much for your help.

Yes. *You didn't include <string>

Correct code:

#include <string>
struct MyStruct
{
* * MyStruct(const std::string& SomeString, const std::string&
AnotherString)
* * {

* * }

};

MyStruct("SomeWord", "AnotherWord");- Hide quoted text -

- Show quoted text -
Correct code is actually:
struct MyStruct
{
MyStruct(const std::string& SomeString, const std::string&
AnotherString)
{
}

};
MyStruct YouHaveToGiveTheMyStructVariableAName("SomeWord",
"AnotherWord");
Mar 3 '08 #4
pa**********@att.net wrote:
On Mar 3, 12:10 pm, red floyd <no.s...@here.dudewrote:
>Yes. You didn't include <string>

Correct code:

#include <string>
struct MyStruct
{
MyStruct(const std::string& SomeString, const std::string&
AnotherString)
{

}

};

MyStruct("SomeWord", "AnotherWord");- Hide quoted text -

- Show quoted text -

Good guess but in fact I did use #include <string>
Thanks a lot for trying to help though.

Any more guesses?
Guesses are all you're going to get. The posted code (with <string>) is
fine.

Try and form a complete example that gives the reported compiler error
and post that.

--
Ian Collins.
Mar 3 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
3
by: Balaji | last post by:
I'm trying to do some basic socket programming. here is the line of code which is creating problem.. int FAR PASCAL __declspec (dllexport)(char * addr,int port) Hers is the error I'm...
2
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project...
2
by: Nick | last post by:
I'm learning C++ and ran into a compile error using Visual C++ 2005 Express on the following example program (located at http://www.cplusplus.com/doc/tutorial/templates.html): // template...
3
by: sphenxes | last post by:
#include <cmath> #include <ctime> #include <cstdlib> #include <iostream> using namespace std; struct Pharmacology{ string genericName; string tradeName; string classification;
2
by: Prashanth Kumar B R | last post by:
Hello, I have the below typedef statements in one of my header file. // // Type Definitions // typedef unsigned long DWORD; typedef unsigned int UINT; typedef unsigned short WORD;
15
by: madhu.ab | last post by:
Hi All, I am getting the following errors when i am including header file winuser.h I dont know whats happening. How will an error occur in winuser.h?? Please help. \microsoft visual...
12
by: jainchar | last post by:
hello to every one please tell me what is the error c2059.In my project it is related to the syntax error in Split function of the Cell class. please help me
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.