Connecting Tech Pros Worldwide Help | Site Map

type

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 19th, 2005, 05:15 PM
Michael Sgier
Guest
 
Posts: n/a
Default type

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, 05:35 PM
Artie Gold
Guest
 
Posts: n/a
Default 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, 05:35 PM
Victor Bazarov
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.