473,320 Members | 1,863 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,320 software developers and data experts.

Strange problem with string

Hello!

I have two very small classes(Head_1 and Head_2) see below and a very small
main.

I have run into a very strange problem. This program doesn't compile but if
I replace
the string type in class Head_2 with for example an int it compile.

If I put a comment out the class definition Head_1 it also compile.

I can't understand this so can anyone explain this to me. I would be very
glad.
#include "head..h"
int main()
{
Head_2 slask2;
return 0;
}

//This is Head..h
**************
class Head_1
{
public:
private:
};

class Head_2
{
public:
private:
string test;
};

Many thanks.

//Tony
Jul 23 '05 #1
2 1252
Tony Johansson wrote:
Hello!

I have two very small classes(Head_1 and Head_2) see below and a very small
main.

I have run into a very strange problem. This program doesn't compile but if
I replace
the string type in class Head_2 with for example an int it compile.

If I put a comment out the class definition Head_1 it also compile.

I can't understand this so can anyone explain this to me. I would be very
glad.


Hi,

i found 2 problems in you program:

1.) You didn`t include the header for C++ string (it is not a "real
fundamental" datatype in c++)
2.) If you included it ... namespace std is missing

try

#include <string>

class Head_2
{
public:
private:
std::string test;
};

int main()
{
Head_2 slask2;
return 0;
}

or

#include <string>
using namespace std;

class Head_2
{
public:
private:
string test;
};

int main()
{
Head_2 slask2;
return 0;
}
regards marbac


Jul 23 '05 #2
Tony Johansson wrote:
Hello!

I have two very small classes(Head_1 and Head_2) see below and a very small
main.

I have run into a very strange problem. This program doesn't compile but if
I replace
the string type in class Head_2 with for example an int it compile.

If I put a comment out the class definition Head_1 it also compile.

I can't understand this so can anyone explain this to me. I would be very
glad.
#include "head..h"
int main()
{
Head_2 slask2;
return 0;
}


Hi,

i found 2 problems in your program:

1.) You didn`t include the header for C++ string (it is not a "real
fundamental" datatype in c++)
2.) If you included it ... namespace std is missing

try

#include <string>

class Head_2
{
public:
private:
std::string test;
};

int main()
{
Head_2 slask2;
return 0;
}

or

#include <string>
using namespace std;

class Head_2
{
public:
private:
string test;
};

int main()
{
Head_2 slask2;
return 0;
}
regards marbac
Jul 23 '05 #3

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

Similar topics

6
by: Sam Sungshik Kong | last post by:
Hello! I'm testing Graphics.DrawString and it's very strange. I created an event handler for the form.s Paint event. (There's no other code in the form.) private void Form1_Paint(object...
2
by: Shapper | last post by:
Hello, I have this code: Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}} Select Case Session("culture") Case "pt-PT" ... Dim cultureList(,) As String =...
5
by: Nathan Sokalski | last post by:
When I view my index.aspx page any time after the first time, I recieve the following error: System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize)...
1
by: Martin Feuersteiner | last post by:
Dear Group I'm having a very weird problem. Any hints are greatly appreciated. I'm returning two values from a MS SQL Server 2000 stored procedure to my Webapplication and store them in...
1
by: Maileen | last post by:
Hi, I finished my application butonce again i have some strange behavior with XML/text functions... for example, here below is a function which worked perfectly till now and now generate an...
8
by: WhiteWizard | last post by:
Have we got a STRANGE one going here. We converted from 1.1 to 2.0 about 2 weeks ago and this has been a problem since then...but only on SOME machines in our development group. The application...
2
by: peter | last post by:
Hi, I have very strange situation but first description ;) I have: 1) project in VB.NET, in this f.e. 1 function: Public Function Login(ByVal UserName As String, ByVal UserPassword As...
3
by: Anup Daware | last post by:
Hi Group, I am facing a strange problem here: I am trying to read xml response from a servlet using XmlTextWriter. I am able to read the read half of the xml and suddenly an exception:...
1
by: Mark Morss | last post by:
Is this the place to ask a win32com.client question? I am a unix person trying to run on windows, so I have little familiarity with this module. I have this code: import win32com.client ...
0
by: charmeda103 | last post by:
when i run my program it runs with no erorrs but the output screen is giving me strange results here is whats its giving me: CONFERENCE OVERALL RANK TEAM W-L % WINS MARGIN W-L ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.