type

M

Michael Sgier

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
 
A

Artie Gold

Michael said:
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

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

HTH,
--ag
 
V

Victor Bazarov

Michael said:
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.

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.
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?

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?
> 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?

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
..
> In VB.NET I only used the predefined types
like int, float etc.

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

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

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top