Connecting Tech Pros Worldwide Help | Site Map

type

  #1  
Old August 19th, 2005, 06:15 PM
Michael Sgier
Guest
 
Posts: n/a
Hi
as im new to C coming from VB.NET where i haven't seen so far
typedeclarations. As I get the error below I don't know what to do.

in main.h:
bool isExtensionSupported(string ext);
and the error:
/src/main.h:164: error: ` string' was not declared in this scope

in main.h I've also included:
# include <string.h>
is that correct? Is it possible to declare any types through a class or
struct like below so I don't need to write anymore float? How would I
access f.ex. y?
class CVector2
{
public:
float x, y;
};
What does the above provide? In VB.NET I only used the predefined types
like int, float etc. I haven't seen the above there...but my career is
still young :-)
Regards Michael
  #2  
Old August 19th, 2005, 06:35 PM
Artie Gold
Guest
 
Posts: n/a

re: type


Michael Sgier wrote:[color=blue]
> Hi
> as im new to C coming from VB.NET where i haven't seen so far
> typedeclarations. As I get the error below I don't know what to do.
>
> in main.h:
> bool isExtensionSupported(string ext);
> and the error:
> /src/main.h:164: error: ` string' was not declared in this scope
>
> in main.h I've also included:
> # include <string.h>
> is that correct? Is it possible to declare any types through a class or
> struct like below so I don't need to write anymore float? How would I
> access f.ex. y?
> class CVector2
> {
> public:
> float x, y;
> };
> What does the above provide? In VB.NET I only used the predefined types
> like int, float etc. I haven't seen the above there...but my career is
> still young :-)
> Regards Michael[/color]

Methinks you need a good book. And soon.
Check http://www.accu.org for suggestions.

HTH,
--ag

--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com (new post 8/5)
http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"
  #3  
Old August 19th, 2005, 06:35 PM
Victor Bazarov
Guest
 
Posts: n/a

re: type


Michael Sgier wrote:[color=blue]
> as im new to C coming from VB.NET where i haven't seen so far
> typedeclarations. As I get the error below I don't know what to do.[/color]

Just to make sure we're on the same page. We talk _C++_ here. C is
a different language and if you need advice on C, visit comp.lang.c.
[color=blue]
> in main.h:
> bool isExtensionSupported(string ext);
> and the error:
> /src/main.h:164: error: ` string' was not declared in this scope
>
> in main.h I've also included:
> # include <string.h>
> is that correct?[/color]

No. You need <string>. And after including <string> the name of the
type is 'std::string', not 'string'. What book are you reading that
doesn't explain that?
[color=blue]
> Is it possible to declare any types through a class or
> struct like below so I don't need to write anymore float? How would I
> access f.ex. y?
> class CVector2
> {
> public:
> float x, y;
> };
> What does the above provide?[/color]

It defines a class named CVector2 (not sure why you'd want 'C' in front
of the name of the class, but hey, who am I to tell you, right?), with
two _members_ 'x' and 'y', each of type 'float'.

You should be able to define an _object_ of type CVector2 now, like this:

CVector2 v;

and that would create an object whose internal data you can access using
the "dot notation":

v.x
or
v.y
..
[color=blue]
> In VB.NET I only used the predefined types
> like int, float etc.[/color]

Too bad. VB has user-defined types as well.
[color=blue]
> I haven't seen the above there...but my career is
> still young :-)[/color]

So, don't waste any time and find a good book.

V
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQLDA corrupted when using VARGRAPHIC type parameters weirdwoolly@googlemail.com answers 9 March 12th, 2007 09:55 AM
Arrays - component type vs Element type Rob Griffiths answers 1 January 23rd, 2006 04:05 PM
Webservice Type is Undefined Chris Fink answers 0 November 23rd, 2005 06:14 AM
Webservice Type is Undefined Chris Fink answers 0 November 23rd, 2005 06:14 AM
struct type completion S.Tobias answers 6 November 14th, 2005 09:43 PM