Im really new to C++

How long will it take me to get somewhat decent at c++ if I practiced around roughly 1 - 2 hours per day? My goal here is to learn allegro or sfml. I do not want to go to opengl or any other 3D supported library since I suck at math.

Below is my first c++ program from just learning in a couple of days.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
using namespace std;

int cal(int);

int main(){

    double kilograms;
    double pounds;

    cout << "Enter the number of Kilograms: ";
    cin >> kilograms;
    pounds = cal(kilograms);
    cout << kilograms << " Kilograms = " << pounds << " Pounds.";

    cin.get();
    cin.get();

return 0;
}

int cal(int kilo){

 return 2.20462 * kilo;

}
Hi Graehme.

just wanted to point out a tiny mistake in your Cal functon

1
2
3
4
int cal(int kilo)
{
  return 2.20462 * kilo;
}


should be:

1
2
3
4
double cal(double kilo)
{
  return 2.20462 * kilo;
}


It's a really easy mistake to make, when you pass a double into this function it will flatten it into an integer, so instead of passing in 1.5 you are actually only passing in 1.

it will then also return an integer so if you passed 1 into your function you would have

2.20462 * 1
which is technically 2.20462

but the function would then convert this back into an integer and would only return 2.

Other than that your code looks great. As long as you keep practicing you will get the hang of it really quickly, Allegro is considerably easier to get started with than sfml but is primarily a C based library without any object orientation.

If you want to work with C++ SFML is probably a better choice and has plenty of documentation. it is also absolutely fantastic.

It's certainly worth jumping in and seeing how far you can get with it

Thanks -NGangst
It's really about how much effort you are willing to put into learning C++, some people learn C++ in few days (yes, they learn pretty much everything about the language in just couple of days) some people take a bit longer to learn C++, if you have any prior programming knowledge then learning C++ won't be so hard, read books and watch youtube lessons tutorials.
Last edited on
1-2 hours a day? About 20 years to achieve mastery.

http://www.wisdomgroup.com/blog/10000-hours-of-practice/

The ability to focus for long periods of time and engage in directed practice is what separates the geeks from the non-geeks. Getting proficient takes less time. About a 10th of that.
Thanks NGangst for the fix and the info!
Well PanGalactic 10,000 hours is considered an expert he wanted to be
decent at c++


If you have a good grasp on the c++ syntax than using SFML will be fairly easy for you.


I would probably suggest doing all the tutorials here and on learncpp then try out SFML.

http://www.cplusplus.com/doc/tutorial/
http://www.learncpp.com/
http://sfml-dev.org/tutorials/2.1/ --SFML
closed account (iAk3T05o)
I can accurately tell you 2-10 years and that 10,000 hours stuff is not applicable to everyone.
Topic archived. No new replies allowed.