Results 1 to 7 of 7

Thread: VB to C++ Conversion

  1. #1
    NOMADMAN
    Guest

    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:
    1. Type WHATEVER
    2.      A as Integer
    3.      B as Boolean
    4.      C as String
    5. 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

  2. #2
    Addicted Member ZanM's Avatar
    Join Date
    Oct 1999
    Location
    The here and now.
    Posts
    191

    Red face 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.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169

    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

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  6. #6
    Addicted Member ZanM's Avatar
    Join Date
    Oct 1999
    Location
    The here and now.
    Posts
    191

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

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width