Jump to content



Photo

Newbie C++ Help


  • Please log in to reply
211 replies to this topic

#196 Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 11
  • Joined: 26-October 05

Posted 11 June 2009 - 03:06

To be honest, with enough motivation you can start with any language. I started with C++ which is very complex and has lots of quirks, but I read my manual from cover to cover and got fairly proficient with it in about 4 months. Then it was really easy to learn C, Python, C#, Java...

It depends on your philosophy. With, say, C#, you can get results very quickly and it's quite intuitive, so it's a less of a steep curve, but then the difficulty ramps up when you try to learn C or C++. If you start with C or C++, then it's hell in the beginning, but once you're through, the worst is behind you, so to speak.

If you're really serious about programming and want to dive right into the meat, C or C++ are sensible options. If you'd rather have a bit of fun doing it and seeing more powerful programs right away, start with C# (Python, Java, Visual Basic are all good options too, but C# is the most C-like and is generally awesome). What's interesting about C# is that you can download a tool called XNA and easily create 2D or 3D games.

With enough perseverance, both routes lead the same way... I'd personally take the fun one.


#197 sp4rki

sp4rki

    Neowinian

  • Joined: 07-November 05

Posted 07 September 2009 - 12:13

I doubt you will score a fulltime career without a CS degree. In my university comp sci classes has a few 40-50 year old people trying to get their degree because they can't even find a job with 20+ years of programming experience.


I just stumbled upon this thread and I HAD to comment on this. Even though a CS degree will help you get through the door and have some (depending on skill, experience, etc) influence on a starting from the "middle" instead of from the bottom (junior programmer vs unpaid intern assisting a programming team), it is absolutely not a requirement most of the time. In this industry it dosen't really matter if you have a degree or not, nor does it matter if you've been on the typing end of a terminal for 10 years. What really matters is skill and branding of your persona. I'll be more specific. If you want to make a career on any type of software engineering industry, you can either: a) Get a CS degree and start working as a programmer (preferably at the same time... no sense in losing time ;) ). After you get your degree and a few years down the line you'll probably have the experience and the education to make an early dive into looking into managerial or higher remuneration positions, be it on your current company or a different one. The most important rule here is to have managers that love you, so as to get recommended. b) If you don't have a degree the most important things are to contribute to opensource projects, have developed a few useful tools, or a program used by many (helps if many == "many of your peers"), maybe write a blog where you document ideas, problems, et al., and most important of all, get your name out there (on and off line). The moment you're known for being a superb programmer with documented success in opensource and with tools and useful (for the community) past programming and/or writing on your toolbelt, you've got what any other college educated software engineer dosen't have. Cred.

PD: Or you can also start doing your own thing. Start a startup of some kind and try to make it big... or strive for slow but steady achievement and build a business form it. Also, this is coming from a Chief Software Architect at a decently sized company, with no degree. Well actually I lie, I do have a degree in Finance, but I got my finance degree a year after becoming a Senior Programmer at a different company and I made little mention of it when I was interviewed for the SA position.

#198 Ryuurei

Ryuurei

    Neowinian

  • Joined: 26-September 09

Posted 05 February 2010 - 17:56

I've been working on some class testing to get back into C++, so I was once again trying to do things in a game-like way.
I created the following code:

#include <iostream>
using namespace std;

//----------Class Player----------
class Player
{
protected:
	int Health, Damage;
public:
	Player() { set(100, 10); }
	Player(int one, int two) { set(one, two); }
	
	int getHealth() { return Health; }
	int getDamage() { return Damage; }
	void set(int newHealth, int newDamage) { Health = newHealth; Damage = newDamage; }
	void Attack(Monster enemy);
};

//----------Class Monster----------
class Monster
{
protected:
	int Health, Damage;
public:
	Monster() { set(100, 10); }
	Monster(int one, int two) { set(one, two); }
	
	int getHealth() { return Health; }
	int getDamage() { return Damage; }
	void set(int newHealth, int newDamage) { Health = newHealth; Damage = newDamage; }
};

//----------Test Function Prototypes----------
void TestPlayerFunctionality();
void TestMonsterFunctionality();
void TestAttackFunction();

//----------Main Function----------
int main()
{
	TestPlayerFunctionality();
	TestMonsterFunctionality();
	//TestAttackFunction();
	system("pause");
	return 0;
}

//----------Player Class Functions----------
void Attack(Monster enemy)
{
	enemy.set(enemy.getHealth() - Damage, enemy.getDamage());
	cout << "After you attack, the enemy's health is " << enemy.getHealth() << "\n";
}

//----------Test Functions----------
void TestPlayerFunctionality()
{
	Player *you = new Player(120, 15);
	cout << "Your health is " << you->getHealth() << "\n";
	cout << "Your damage is " << you->getDamage() << "\n";
	delete you;
}

void TestMonsterFunctionality()
{
	Monster *baddy = new Monster(20, 3);
	cout << "Monster's health is " << baddy->getHealth() << "\n";
	cout << "Monster's damage is " << baddy->getDamage() << "\n";
	delete baddy;
}

void TestAttackFunction()
{
	Player *you = new Player(120, 20);
	Monster *baddy = new Monster(100, 15);
	you->Attack(baddy);
	
	delete you;
	delete baddy;
}

and just about everything works (although I commented out the TestAttackFunction() test to be worked on later.
Upon compiling the code I have there, I receive the following errors:
Line 16: "syntax error : identifier Monster"
Line 51: " 'Damage' : undeclared identifier"
Line 76: "Player::Attack function does not take 1 argument"

I've revisited the Monster class, and it seems to be fine to me.
The Damage variable IS obviously declared within either class (including the Player class which the function refers).
The Player::Attack function does indeed take one argument, this makes no sense.

I was using references, such as "void Attack(Monster const &enemy);" but doing so brought up even more, less understandable errors.
Can anyone figure out what's going on here, because it is totally eluding me.

#199 winlonghorn

winlonghorn

    Neowinian

  • Joined: 17-March 05
  • Location: Erie, PA

Posted 08 February 2010 - 08:29

I've been working on some class testing to get back into C++, so I was once again trying to do things in a game-like way.
I created the following code:

#include <iostream>
using namespace std;

//----------Class Player----------
class Player
{
protected:
	int Health, Damage;
public:
	Player() { set(100, 10); }
	Player(int one, int two) { set(one, two); }
	
	int getHealth() { return Health; }
	int getDamage() { return Damage; }
	void set(int newHealth, int newDamage) { Health = newHealth; Damage = newDamage; }
	void Attack(Monster enemy);
};

//----------Class Monster----------
class Monster
{
protected:
	int Health, Damage;
public:
	Monster() { set(100, 10); }
	Monster(int one, int two) { set(one, two); }
	
	int getHealth() { return Health; }
	int getDamage() { return Damage; }
	void set(int newHealth, int newDamage) { Health = newHealth; Damage = newDamage; }
};

//----------Test Function Prototypes----------
void TestPlayerFunctionality();
void TestMonsterFunctionality();
void TestAttackFunction();

//----------Main Function----------
int main()
{
	TestPlayerFunctionality();
	TestMonsterFunctionality();
	//TestAttackFunction();
	system("pause");
	return 0;
}

//----------Player Class Functions----------
void Attack(Monster enemy)
{
	enemy.set(enemy.getHealth() - Damage, enemy.getDamage());
	cout << "After you attack, the enemy's health is " << enemy.getHealth() << "\n";
}

//----------Test Functions----------
void TestPlayerFunctionality()
{
	Player *you = new Player(120, 15);
	cout << "Your health is " << you->getHealth() << "\n";
	cout << "Your damage is " << you->getDamage() << "\n";
	delete you;
}

void TestMonsterFunctionality()
{
	Monster *baddy = new Monster(20, 3);
	cout << "Monster's health is " << baddy->getHealth() << "\n";
	cout << "Monster's damage is " << baddy->getDamage() << "\n";
	delete baddy;
}

void TestAttackFunction()
{
	Player *you = new Player(120, 20);
	Monster *baddy = new Monster(100, 15);
	you->Attack(baddy);
	
	delete you;
	delete baddy;
}

and just about everything works (although I commented out the TestAttackFunction() test to be worked on later.
Upon compiling the code I have there, I receive the following errors:
Line 16: "syntax error : identifier Monster"
Line 51: " 'Damage' : undeclared identifier"
Line 76: "Player::Attack function does not take 1 argument"

I've revisited the Monster class, and it seems to be fine to me.
The Damage variable IS obviously declared within either class (including the Player class which the function refers).
The Player::Attack function does indeed take one argument, this makes no sense.

I was using references, such as "void Attack(Monster const &enemy);" but doing so brought up even more, less understandable errors.
Can anyone figure out what's going on here, because it is totally eluding me.


Are your classes in seperate files? If so, be sure to add "#include <monster.h>" at the top of the player class. Also, it is very difficult to follow the organization of this code. I see the function prototypes, but I do not see the seperate function implementations. For example:

void Player::Attack(Monster enemy)
{
}

Those have to be outside of the class itself. :)

#200 jtrag

jtrag

    Neowinian

  • Joined: 22-October 08

Posted 09 July 2010 - 07:21

[edit] wouldn't be bad to make this a sticky thread, so others may be able to use it without me repeating myself. This is a very common question here.[/edit]



if you don't have a compiler (to make .exe) go to http://www.bloodshed.../dev/index.html download version 4, version 5 is a buggy beta. if you do dl ver.5, then update .exe using cvs at sourceforge.



As for books go, the best one is "The c++ programming language" by Bjarne Stroustup (the inventer of c++) is the best. Itis one of those books that from a beginner to Linus Torvalds (linux guy) and developpers use.



edit: the sites below all helped me in some way or another. First you should learn c programming, then move on to c++ and win32api and other api's.



http://www.cplusplus.com/doc/tutorial/ This site covers a lot! I learned a lot of Object Oriented Programming from here.

http://www.cplusplus.com/ref/ This is a handy site for beginners. This has examples and instructions for many standard library functions.

http://www.sgi.com/tech/stl/ This is handy resource. Most of functions show prototypes and explenations for all of STL.

http://www.allegro.cc This has an easy to use complete game programming library. It's well evolved and used. It supports directx hardware accel through its functions.

http://www.sourceforge.net This is for those of you interrested in developping open source, giving feedback, bug reporting, latest builds, and complete code of some of your favorite apps... and much much more.

http://oopweb.com/CPP/Files/CPP.html This has a list of many tutorials and other resources.

http://www.msdn.microsoft.com A developer's ultimate resource.

http://www.winprog.org/tutorial The best site for learning windows programming. The guy set out to make it easy and quick. I think he certainly achieved his goal.

http://www.cprogramm...m/tutorial.html another c tutorial

http://www.research....s/homepage.html The inventors home page.


Nice tips/resources! Thanks for sharing!

#201 holisms

holisms

    Resident One Post Wonder

  • Joined: 09-February 12

Posted 09 February 2012 - 13:14

Friend, nothing is better than internet to search C & C++ tutorial and you have to check which one is better for you because there is lot of tutorials. you can check also cplusplus.com.

#202 Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 11
  • Joined: 26-October 05

Posted 11 June 2012 - 14:13

I have used few of your mentioned links, all are great and have good information but many of them have difficult data to understand C# I am in search of a website with detail explanation of C# with easy steps.

The C# Yellow Book.

#203 simplezz

simplezz

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 01-February 12

Posted 11 June 2012 - 14:39

1. Start off with C. It's far simpler, and C++ inherits most of it, therefore, the knowledge is transferable.
2. Don't use an IDE, at least not to begin with. They just get in the way of understanding how to program, compile and debug. A simple text editor (CLI or GUI) is all that is needed to edit the code. I like Vim personally. Although Emacs is pretty good too.
3. Use a standards compliant FOSS compiler and make system. That way, you won't be locked-in to any one platform. I recommend GCC and the auto tools. It's called MinGW (Minimalist GNU for Windows) on Windows.

It's even possible to write C code targeting GNU/Linux that runs without modification on Windows by using Cygwin, which also happens to give you a Linux-like development environment.

However, if you're adamant about using C++, definitely look into Boost (C++ library), it's the defacto standard for C++ development, and fills in many of the gaps in the STL.

http://gcc.gnu.org/

#204 computer_guy04

computer_guy04

    Neowinian

  • Joined: 30-December 04
  • Location: Triad NC, USA

Posted 13 July 2012 - 06:12

Hey guy's I have read through the responses and like the advice. I was just getting ready to post a question asking if there was such a program out there that taught you C++ kinda like the old Mavis Beacon software.

#205 enc_MAYhem

enc_MAYhem

    enc_MAYhem

  • Joined: 17-November 12
  • Location: India
  • OS: Windows 8
  • Phone: HTC Desire C

Posted 17 November 2012 - 02:45

Can you guys recommend a decent IDE + compiler all in one? cause i have been using Dev C++ and it ****s at IDE standards.. some people told me to use Notepad++ which again is a good IDE but i then need to add the code to DevC again! i tried borland and the other one which is turbo c++ which pretty much suck to.

I like the IDE from the Notepad++

anyway also are there any IDE's/compilers who like automatically complete/format a command when we start typing? that would be really great and save alot of time i believe..

like for eg: when i start with a for loop and i type in for it automatically enters for() { } and then i can maybe enter the source code myself?

thanks.

#206 +Karl L.

Karl L.

    xorangekiller

  • Tech Issues Solved: 15
  • Joined: 24-January 09
  • Location: Virginia, USA
  • OS: Debian Testing

Posted 17 November 2012 - 03:20

Personally I use Notepad++ as my editor and g++ (MinGW) as my compiler (via makefiles) when programming for Windows in C++. As a beginner, that is probably a bit complicated for you and I don't recommend you try it until you get more experience.

Visual Studio Express is a popular choice if you are using Windows (which I assume is the case based on your mention of Notepad++). Although its C++11 support is as-of-yet somewhat incomplete, it is a good IDE with an excellent debugger.

Although I have not used it, from what I have heard Code::Blocks is also an excellent IDE with a solid C++ compiler and a good debugger.

#207 Colin McGregor

Colin McGregor

    Neowinian Senior

  • Joined: 02-September 11
  • Location: Ontario, Canada
  • OS: Windows 8 x64, Gentoo x64 Sometimes
  • Phone: Samsung Ativ S WP8

Posted 17 November 2012 - 03:29

I use VS Express. Its much better now as well now that its one install for everything instead of before when you had to install C# express, C++ express, VB Express etc..

I grabbed VS 2012 Express today and it was one setup one install.

#208 enc_MAYhem

enc_MAYhem

    enc_MAYhem

  • Joined: 17-November 12
  • Location: India
  • OS: Windows 8
  • Phone: HTC Desire C

Posted 17 November 2012 - 09:55

Thanks for the suggestions, i'll try out the visual studio by microsoft.. should i be getting the 2012 edition or the older versions are just easier to operate or something?

#209 +Karl L.

Karl L.

    xorangekiller

  • Tech Issues Solved: 15
  • Joined: 24-January 09
  • Location: Virginia, USA
  • OS: Debian Testing

Posted 19 November 2012 - 18:05

Now that Microsoft has released a version of Visual Studio 2012 Express that can develop desktop applications, I definitely recommend that you download that one. Use the link that I provided a couple of posts back to go to the product information page, or use this link to download the ISO directly.

#210 00xxzeroxx00

00xxzeroxx00

    Resident One Post Wonder

  • Joined: 01-February 13

Posted 01 February 2013 - 22:55

hi i just want to know what is the reason for this code note work:

#include <iostream.h>
int main()
{
int table [500,5];
for(int i=0;i<500;i++)
for(int j=0;j<5;j++)
table [i,0]=i;
cout<<table;


return 0;
}