|
-
Jan 28th, 2002, 01:21 AM
#1
VB to C++ Conversion
I know VB, well to very well, but I don't know C++ that well.
I have Newbie knowledge of C++...
In VB you can declare Types
VB Code:
Type WHATEVER
A as Integer
B as Boolean
C as String
End Type
you get the idea! How is this done in C++? Can it be done?
Also, second question, I've heard the words Class, Method, Objects... how does this all fit togeter. Like are classes methods of something. Methods have classes in them? I dunno.
Could some one clear this up?
Thanks
NOMAD
-
Jan 28th, 2002, 02:15 AM
#2
Addicted Member
ok here it is basicly
what we call a type in vb is called a structure in c++ and that is what it realy is in vb
Code:
Type SomeType
A as Integer
B as Integer
End Type
in C++ it looks like this
Code:
struct SomeStruct {
int a;
int b;
};
they are basicly the same thing and they both use dot syntax ie
Code:
Dim mType as SomeType
mType.A = 450
Code:
SomeStruct mStruct;
mStruct.a = 450
thats it basicly for types and structs
before i even start to explain the relation between vb classes and c++ classes you should be sure you understand encapsulation, code reuse and the general concepts of COM not really a copmlete understanding of COM in VB is necesary but it helps things to be clear as to if you need a class or not. do you have something that you need to maintain info on or that needs to be able to do things for itself that couldn't be done to a function call that was common to the whole application and not just to an instance of the object's class
if you think you understand classes in vb thier properties and methods i will take the time to make an example but if you aren't sure so so because you'll be lost if you don't understand let,get,set, public, private and friend as they work within a vb class
Last edited by ZanM; Jan 28th, 2002 at 02:22 AM.
Magiaus
Visual Basic 6.0 SP5
Visual C++ 6.0 SP5
The only sovereign you can allow to rule you is reason.
-
Jan 28th, 2002, 01:46 PM
#3
He doesn't ask about COM or the special things of VB classes but about OOP in general. And I suggest he uses a C++ tutorial to find out about it (see topmost post)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 28th, 2002, 02:17 PM
#4
Monday Morning Lunatic
Re: ok here it is basicly
Originally posted by ZanM
Code:
Type SomeType
A as Integer
B as Integer
End Type
in C++ it looks like this
Code:
struct SomeStruct {
int a;
int b;
};
Uh...it's not int, it's short. In VB an Integer is only two bytes
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 28th, 2002, 03:59 PM
#5
That's ok, but again datatype mistake.
C float == VB Single (4 bytes)
VB Double = C double (8 bytes)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 28th, 2002, 07:51 PM
#6
Addicted Member
hmmm
maybe i should learn more about not being a newbie myself before i try to tech others, i'm used to it being called a float in vb books
Magiaus
Visual Basic 6.0 SP5
Visual C++ 6.0 SP5
The only sovereign you can allow to rule you is reason.
-
Jan 29th, 2002, 08:33 AM
#7
Well, that's naming:
VB:
Single = single precision floating point number
Double = double precision floating point number
C:
float = floating point number
double = double precision floating point number
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|