English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

My best friend is on his last week of a C++ programming class and has taken it twice. Just not clicking, although, he is super smart in other programs. What to do? Any advice? Someone to help him through?

2006-09-26 15:58:40 · 7 answers · asked by kbear1274 3 in Computers & Internet Programming & Design

7 answers

*** if you need help, send an email to switch@gmail.com I remember when I had trouble with C++ quite a few years back. ***

Main thing to understand about C++ (especially in a beginner's class like the one he is taking) is the notion of 'objects'.

In C++, a 'class' is an object.

A class is a fancy word for 'data structure'.

This special data structure contains variables used to define properties of the class, and functions to interact with these properties.

After defining the properties and functions inside a class, you have to use it!

To do this, you create a new instance of your class inside your program as you would with other data structures such as int's, char's, etc.

The cool thing about classes is that you can tailor them to fit your program functionality, and it helps organize your code. It's like a 'struct' on steroids (since it has functions associated with it).

There are 3 types of properties/functions in a class:
public/private/protected

public properties/functions are accessible from your main program functions.

private properties/functions are only accessible from the functions defined in your class.

protected properties/functions are only accessible from the functions defined in your class, and any other classes that derive from your class (these classes you would also define - think 'inheritance').

You can define a new class that inherits properties/functions of another class. Your new class basically takes all of the properties and functions in the parent class, and also makes use of new ones you define.

For example, if you create a class B by inheriting class A, your new class is pretty much A + (more functions/properties defined in B).

By declaring certain functions in class A as 'virtual', you can redefine these functions in class B to fit what you are trying to do.

For example:

class Shape { ...public: virtual draw(); };
class Circle : public Shape { ...public: virtual draw(); };
class Square : public Shape { ...public: virtual draw(); };

In your main program, you can define an array of pointers shapes, but each element can point to a circle or square. this makes traversing the array a lot easier since you are dealing with one class defined two different ways. obviously, circles and squares are drawn differently, but you are treating both as a shape. In the above example, Circle and Square inherit public functions (and their associated variables) from Shape. If you understand this, you understand 'polymorphism'.

2006-09-26 16:29:31 · answer #1 · answered by cypherkey 2 · 0 0

No way to get around it. He just has to put some genuine effort in trying to understand object oriented programming.

This question is too vague for me to give you any concrete answer but C++ is not that difficult to learn and the only thing I can tell you is that he needs to due his part and study a little or get a tutor from school. This stuff is not going to be just picked up when you don't have the basic concepts down and it may take some time to click.

2006-09-26 16:04:06 · answer #2 · answered by cantankerous_bunch 4 · 0 0

Sounds like he might not be getting the basics down.
I'd suggest a review, as variables build loops and loops build to functions, etc. It's easy to get lost when starting out.

Try http://www.cplusplus.com/doc/tutorial/

2006-09-26 16:12:25 · answer #3 · answered by Anonymous · 0 0

sounds like "your friend" needs to think about a different career. passing a class is the easy part of software development. the REAL test is when "this friend" gets a job and has to do the development by him/her self. no one there to "help" you through it, you have to do it all by yourself.

2006-09-27 02:24:49 · answer #4 · answered by justme 7 · 0 0

what is the part where your friend is having problems.
arrays,pointers, structures?
send more information so i can be of help

2006-09-26 16:22:59 · answer #5 · answered by SUAVE38 2 · 0 0

When you say "my friend" do you mean you?

2006-09-26 16:05:22 · answer #6 · answered by You're My Wonderwall 3 · 0 0

c++ or c++.Net

2006-09-26 16:00:56 · answer #7 · answered by shahidrock 3 · 0 0

fedest.com, questions and answers