Board index » cppbuilder » Default strings

Default strings


2004-02-02 07:16:12 PM
cppbuilder43
Hi,
I made a class in BCB6 and would like to use it in other compilers, but as soon as I tried to compile it in Microsoft Visual Studio .net I get errors about types.
I have not included the vcl.h and am using the "string mystring" for my strings, which Iíve read, is a basic_string type.
I donít really want to use char* as i seem to be having a few problems with it and as the code is all based around the string type I'd like to use a default string type if I could have only have to revert to char* if I recall need to.
Thanks for your input,
MwnN
 
 

Re:Default strings

MwnN wrote:
Quote
I made a class in BCB6 and would like to use it in other compilers, but as soon as I tried to compile it in Microsoft Visual Studio .net I get errors about types.

I have not included the vcl.h and am using the "string mystring" for my strings, which Iíve read, is a basic_string type.

I donít really want to use char* as i seem to be having a few problems with it and as the code is all based around the string type I'd like to use a default string type if I could have only have to revert to char* if I recall need to.
You definitely can use strings with VS. It's hard to tell what's going
wrong since you don't give us any code but did you #include <string>in
your file? Did you declare your strings like this:
std::string mystring;
or did you use a using directive?
Michel
--
----------------------------------------
Michel Leunen
mailto: XXXX@XXXXX.COM
C++Builder, C++BuilderX, BCC5.5.1 Web site:
www.leunen.com/
----------------------------------------
 

Re:Default strings

Michel Leunen wrote:
Quote
You definitely can use strings with VS. It's hard to tell what's going
wrong since you don't give us any code but did you #include <string>in
your file? Did you declare your strings like this:
std::string mystring;
or did you use a using directive?
aa, I see, I didn't have the std::, just the 'string mystring',
seems not to complain anymore about it ;) Thanks!
On another note. In my call I have a private structure, which I
can access by means of
/* example code */
typedef struct
{
bool NorthOrEast; // North=Latitude, East=Longitude
double Degrees, Minutes, Seconds, Meters, Feet;
}LonLatData;
// -------------------------------------------------------------
typedef struct
{
int Zone;
std::string NAC;
LonLatData LAT;
LonLatData LON;
}NACStruct;
// -------------------------------------------------------------
class TNACConverter
{
private:
NACStruct FData; // settings and values
public::
TNACConverter();
__property NACStruct Data = {read=FData, write=FData};
};
Although __property is highlighted as a keyword MSVS.net
doesn't seem to like me using it in this manner (as i would in
BCB). Can you suggest anything I might require in order to get
it compiling?
Thanks again,
MwnN
 

{smallsort}

Re:Default strings

MwnN wrote:
Quote
__property NACStruct Data = {read=FData, write=FData};
Although __property is highlighted as a keyword MSVS.net
doesn't seem to like me using it in this manner (as i would in
BCB). Can you suggest anything I might require in order to get
it compiling?
You can't. __property is a Borland add-on to the language. It is not
supported by other compilers. There is maybe some kind of property in
MSVS but I'm not aware of. If you want to write cross-compiler code,
stay away from these things and write standard C++. In this case, your
best bet is to use the classical setter/getter functions:
NACStruct GetData()const {return FData;}
void SetData(const NACStruct& value) {FData = value;}
Michel
--
----------------------------------------
Michel Leunen
mailto: XXXX@XXXXX.COM
C++Builder, C++BuilderX, BCC5.5.1 Web site:
www.leunen.com/
----------------------------------------