Jump to content
  • Advertisement
Sign in to follow this  
kmart

Java to C++

This topic is 4165 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am proficient in Java, and was wondering how hard/what resources to switch to C++ for a more mainstream game design approach. Basically the questions I have are to create super and sub classes in C++. I'm using DEV-C++ and when I create a class file it creates a .cpp file and a .h file. So say in java if I want to class Person { private String name; private int age; private double weight; public Person(String newName, int newAge, double newWeight)//Constructor { name = newName; age = newAge; weight = newWeight; } //End of constructor } //End of class ******************************************** class Student extends Person { private char grade; private double final_score; public Student(String newName, int newAge, double newWeight, char newGrade, double newScore)//Constructor { super(newName, newAge, newWeight); grade = newGrade; final_score = newScore; }//End class then the main class will contain the following code String name = "Joe"; int age = 20; double weight = 190.9; char grade = 'A'; double final = 100; Student Stu1 = new Student(name,age,weight,grade,final); ..... and so forth. So if someone could help me design basically the same thing in C++ or lead me to a resource for OOP in C++ I'd appriciate it greatly.

Share this post


Link to post
Share on other sites
Advertisement
I'll second that suggestion on account of having previously read and enjoyed/learned from Bruce Eckel's other book, Thinking in Java. His writing style is very accessible and he usually provides contextual information that goes way beyond a simple instruction-style manual.

Share this post


Link to post
Share on other sites
The code is actually very similar. I would suggest looking at some basic tutorials about OOP in c++. Their all over the net and would save you the time of learning the whole C++ language. (unless of course you want to)

Share this post


Link to post
Share on other sites
being a user of both java and c++ (at a basic level) There are differences but it was pretty easy for me to pick up java after learning c++... Java is just more oop... but with c++'s flexibility you can make it as OO as you want.
-durfy

Share this post


Link to post
Share on other sites
Thanks for everyone's help.

I guess my biggest source of confusion was why it was creating two files when I wanted a new class.

But I'm sure reading the resources will provide the help I need.

Share this post


Link to post
Share on other sites
Quote:
Original post by kmart
I guess my biggest source of confusion was why it was creating two files when I wanted a new class.


The definition goes in the .h file and the methods go into the .cpp file.

But youll get into that when you reach classes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!