Results 1 to 4 of 4
Like Tree2Likes
  • 2 Post By KevinWorkman

Thread: How Do I: Convert to Java

  1. #1
    mexists's Avatar
    mexists is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Question How Do I: Convert to Java

    Hi buddy, do you know how to convert this C++ code into Java? I'm still fairly new to Java, hope you can guide me
    Microsoft Visual C++ 2010

    #include "stdafx.h"
    #include<iostream>
    using namespace std;
    template<typename T>
    class myShape{
    protected:
    T height, width;
    };

    template<typename T>
    class CSquare : public myShape<T>
    {
    public:
    CSquare(int height, int width){
    this->height = height;
    this->width = width;
    }

    T area(){
    return this->height * this->width;
    }
    };

    int _tmain(int argc, _TCHAR* argv[])
    {
    CSquare<int> *s = new CSquare<int>(3,4);
    cout<<s->area();
    }

    ...by the way, if you familiar with C++, please help me here to fix the Turbo C++ 4.5 code. Thanks friends

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,648
    Blog Entries
    7
    Rep Power
    21

    Default Re: How Do I: Convert to Java

    Java has generics; they (sort of) do what C++s templates do; read a tutorial on the subject, for simple use they aren't very different.

    kind regards,

    Jos

    ps. I deleted your other identical thread and made this one visible to all.
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,984
    Rep Power
    9

    Default Re: How Do I: Convert to Java

    Did you not like the help you already received elsewhere?

    Crossposted: How Do I: Convert to Java
    Fubarable and DarrylBurke like this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    mexists's Avatar
    mexists is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Re: How Do I: Convert to Java

    okay, i get it! thanks for your time guys.. i'm sorry if i'd vexatious you.. i'm really really sorry... :-h

    Problem Solved!

Similar Threads

  1. How can I convert java files to exe?
    By manolis_kakou in forum Advanced Java
    Replies: 6
    Last Post: 07-21-2010, 02:56 PM
  2. Convert C++ code to Java
    By napoleon in forum New To Java
    Replies: 2
    Last Post: 03-07-2010, 07:44 AM
  3. how to convert * into : using java
    By Ricks in forum New To Java
    Replies: 2
    Last Post: 02-02-2010, 04:57 PM
  4. Convert .java to .exe
    By susan in forum New To Java
    Replies: 6
    Last Post: 02-11-2009, 06:47 AM
  5. Convert java to .exe
    By heartysnowy in forum New To Java
    Replies: 13
    Last Post: 11-21-2008, 08:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •