By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,131 Members | 1,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,131 IT Pros & Developers. It's quick & easy.

type

P: 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
Aug 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Michael Sgier wrote:
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

--
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!"
Aug 19 '05 #2

P: n/a
Michael Sgier wrote:
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
Aug 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.