|
-
July 3rd, 2002, 08:33 AM
#12
I will give an example of the difference between c and c++
/* C Code */
struct stack
{
An example
/* C code*/
struct stack
{
int elt[100];
int top ;
}s;
void push(int x)
{
/* code to push*/
}
int pop()
{
/* code to pop*/
}
void main()
{
int i;
s.push(100);
i = s.pop();
}
// c++ code
class stack
{
private :
int elt[100],top;
public:
void push();
int pop();
} s;
main()
{
int i;
s.push(100);
i = s.pop();
}
U can clearly see that in C++ , not only the properties(say variables), but also the methods(functions) to act on those variables are part of the datatype.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|