i am new to c++ and i'm try to write a code that reads integers of a text file and saves each integer in different variables in a class.I am having problems with the syntax and how to arrange the code. Basically the text file contains 4 integers per line which values are to be read to the a class planet's coordinates and ID as shown below. I know the code below is incomplete but this is the first time im programming with c++ and need help. please you do not need to explain this using planets or anything. I just need a general understanding
using namespace std;
planet* generate_planet(istream &fin)
planet *the_planet= new planet();
first off, add a space between your planet* and generate_planet(istream &fin). The compiler treats this as a pointer to a generate_planet object(instead of treating it as a function name).
secondly, you never delete your dynamically allocated object in generate_planet, this causes memory leaks and can be extremely bad for your program. Make sure you delete it at some point in the program(end preferably).
You might want to think about looking over the concepts of c++ more, i see a lot of logical and semantics errors. Public variables...memory leaks...strange functions...etc...etc..