LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

So, I need help with C++

Root / General / [.]

answerCreated:
I'm coming from Java and now I'm starting to work with C++, I understand most of the syntax necessary for the language but I'm really confused, I can't find a JFrame equivalent anywhere. And most apis don't even compile correctly on Geany, so, what do you recommend me doing This is a programming question :P

I'm not the most experienced with C++, but I'll try to help as much as I can. I think that if you need something like JFrame for C++ on Linux, OpenGL is the most common thing to use. Though I'm pretty sure that OpenGL doesn't have as much frame using, you can always then create your own classes for internal window objects. If your apis aren't compiling correctly in your IDE, you can always compile the code yourself in a terminal. That's how I compiled all of my Linux C code. Obviously using an IDE is nice though, so you may want to look for another one on Linux (I don't know any Linux IDEs though, so I can't really help you there).

I'll try using OpenGL, then compiling from the terminal if that still doesn't compile properly Thx

Technically speaking, there is no JFrame equivalent that works on all OSs. This is a platform specific process. Windows, for example, requires the the programmer to use winMain and that they register a window processing function which is able to accept events from things like buttons, clicks, and other stuff. One library that I used in the past was wxWidgets which is a cross platform library. If you need it to be cross platform I have included a link to a list of libraries that help with that. If it doesn't matter than I suggest you lookup the API documentation for your OS. If you are using windows than I would not mind helping at all. Also, creating an OpenGL window with your own custom button classes is a valid approach, but still requires creating a window (which is platform specific). You can take that approach and be lazy like me with SDL! https://en.wikipedia.org/wiki/List_of_platform-independent_GUI_libraries

C++ is like.... THE hardest route to go if you want to make games. Seriously, I wouldn't recommend it. I mean, ALL game programming outside of an environment made for games is going to be tough. However, C++ is just atrociously confusing, and unnecessarily so. You'll be fighting the language more than the game making, which isn't what you want. I'm not just saying this because I hate C++ and don't understand it. I'm saying it because I care about your sanity.

C++ is like.... THE hardest route to go if you want to make games. Seriously, I wouldn't recommend it. I mean, ALL game programming outside of an environment made for games is going to be tough. However, C++ is just atrociously confusing, and unnecessarily so. You'll be fighting the language more than the game making, which isn't what you want. I'm not just saying this because I hate C++ and don't understand it. I'm saying it because I care about your sanity.
Well, I'm trying to learn C++ because I know it'll be worth the pain and the struggle of learning, because it's what many operating systems call "native" and is most used in the industry of video games Edit: My parents a while ago bought me AGK, but I currently have no access to it :/ https://www.appgamekit.com

Technically speaking, there is no JFrame equivalent that works on all OSs. This is a platform specific process. Windows, for example, requires the the programmer to use winMain and that they register a window processing function which is able to accept events from things like buttons, clicks, and other stuff. One library that I used in the past was wxWidgets which is a cross platform library. If you need it to be cross platform I have included a link to a list of libraries that help with that. If it doesn't matter than I suggest you lookup the API documentation for your OS. If you are using windows than I would not mind helping at all. Also, creating an OpenGL window with your own custom button classes is a valid approach, but still requires creating a window (which is platform specific). You can take that approach and be lazy like me with SDL! https://en.wikipedia.org/wiki/List_of_platform-independent_GUI_libraries
Wow, this is a great resource; maybe I'll get SDL as an option for side use for the future :)

Well, I'm trying to learn C++ because I know it'll be worth the pain and the struggle of learning, because it's what many operating systems call "native" and is most used in the industry of video games Edit: My parents a while ago bought me AGK, but I currently have no access to it :/ https://www.appgamekit.com
It's totally not worth the pain and struggle unless you're making a AAA game that requires the utmost optimization. You can still make awesome 3D games without using C++. As for the operating system stuff, unless you're going to be writing your own kernels and whatever, you probably don't need C++. Seriously, I think people push new programmers to learn C++ so that there are less programmers in the field O.o

It's totally not worth the pain and struggle unless you're making a AAA game that requires the utmost optimization. You can still make awesome 3D games without using C++. As for the operating system stuff, unless you're going to be writing your own kernels and whatever, you probably don't need C++. Seriously, I think people push new programmers to learn C++ so that there are less programmers in the field O.o
I'm not making any 3D games, I'm more interested in a graphics experience similar to SmileBASIC really :)

You can do what you like, but if your goal is to make 2D games, I would steer clear of C++. Here's a little bit of the "why" behind my advice:
  • C++ was created as an extension to C. As an extension, it simply appended features to the language rather than redesign it. As a result, it was messy and bloated. Imagine trying to "fix" a song by adding more tracks to it.
  • C++ relies heavily on symbols to convey meaning. This means that you'll be staring at ::<<>>~? a lot and going "what the hell does all this mean"
  • C++ allows you to program in many different ways, which usually leads to people using anti-patterns. Anti-patterns might make your code work, but it won't make any sense and it'll be hard to change.
  • Both strings and dynamic memory in C++ are an absolute nightmare. You'll find people using the C style, using the C++ style, or mixing the two based on their mood. This is true for many other things in C++, meaning tutorials can quickly get confusing.
These are some of the unnecessary questions you'll be asking yourself when you learn C++: Why does one person use string and others use char*? And why can I sometimes use char* and other times use char[]? And what is string*? Why do some functions require char* and others require string, and how am I supposed to know which is which? Why do some people use stdio.h and others use cstdio, and why does #include change from <> to ""? Why is this person using malloc(sizeof(int) * 10) and this other guy is using new int[10]? Why do some people use std::cout and others just do cout? Why do some people use structs and others use classes, and why is there even a difference? What's the deal with size_t and why can't I just use integer? What the hell is a long long, and why is it the same as long? Furthermore, why is there long, long long, and long int, and why are they all the same? Seriously, instead of learning programming, you're going to be learning the ins and outs of an overly complex mashup of a language, most of which can't be applied to other languages. If you're looking for low level programming with concepts that are applicable to other languages, I suggest learning C instead. If you're just looking to program a game, find another language. Any other language.

These are some of the unnecessary questions you'll be asking yourself when you learn C++: Why does one person use string and others use char*? And why can I sometimes use char* and other times use char[]? And what is string*? Why do some functions require char* and others require string, and how am I supposed to know which is which? Why do some people use stdio.h and others use cstdio, and why does #include change from <> to ""? Why is this person using malloc(sizeof(int) * 10) and this other guy is using new int[10]? Why do some people use std::cout and others just do cout? Why do some people use structs and others use classes, and why is there even a difference? What's the deal with size_t and why can't I just use integer? What the hell is a long long, and why is it the same as long? Furthermore, why is there long, long long, and long int, and why are they all the same?
Wow, thank you; I guess it's all of this because C++ is just an extension and not its own language meaning it can be the most confusing thing; C is probably a better option if that's the case, thank you for putting sense into me

randomouscrap makes an excellent point. C++ by itself is very confusing syntax wise. It's like a county fair; it is crowded and half the time you don't know what's going on. If you are just starting, I would definitely recommend starting out with a more "vanilla C" approach. I would like to point out that Javascript and C have very similar syntaxes. once you get the hang of using C you can incorporate some C++ constructs like classes and whatnot, but still keep a syntax that looks like C. Although, I would like to say that the whole string type mess that you have in C/C++ has always bothered me. :P Personally I just stick with char* which is easy to understand/manipulate. Here are two resources that I have (and still) use time and time again when programming. Learning C/C++: http://www.cprogramming.com/ Function references and other useful stuff: http://www.cplusplus.com/ Just a word of advice when learning this language(s). Be very VERY careful when dealing with pointers. Going beyond the bounds of them causes the dreaded "undefined behavior," that may or may not crash a program.

If you want the power of C in the simplicity of BASIC, check out FreeBASIC. It's basically VB.NET, but compiles directly to C, so you'll get pretty-close-to-native speeds, and it'll definitely make the major part of your life much easier!

If you want the power of C in the simplicity of BASIC, check out FreeBASIC. It's basically VB.NET, but compiles directly to C, so you'll get pretty-close-to-native speeds, and it'll definitely make the major part of your life much easier!
Sounds interesting, I may look into it later

randomouscrap makes an excellent point. C++ by itself is very confusing syntax wise. It's like a county fair; it is crowded and half the time you don't know what's going on. If you are just starting, I would definitely recommend starting out with a more "vanilla C" approach. I would like to point out that Javascript and C have very similar syntaxes. once you get the hang of using C you can incorporate some C++ constructs like classes and whatnot, but still keep a syntax that looks like C. Although, I would like to say that the whole string type mess that you have in C/C++ has always bothered me. :P Personally I just stick with char* which is easy to understand/manipulate.
Yeah, I feel like using a more classic C approach is more promising, I've already started the C tutorial on cprogramming.com and it's very well built, maybe once I've burnt out C, I'll possibly be able to look into C++ since I would understand the bases of the language at least

I'd reccommend using CSS instead

I'd reccommend using CSS instead
Haha good luck with that Learning C++ from a non-C background can be extremely difficult if not approached properly, mainly grasping the whole idea of pointers, and dereferencing them to read the value at its address. But C++ is the language to go with if you plan on making games, it has the speed of C and an object oriented syntax like Java. It's a very very powerful language, and if you take any Computer Science classes in college, chances are you will be using C++ A LOT. I encourage you to learn C++, i'm just saying, you will spend countless hours, full nights, days, maybe weeks just staring at your 'perfect code' only to realize you made a tiny mistake, or your pointers were not properly set, the syntax is very strict, which has its pros and cons to it.