Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-14-2005, 07:20 AM   #1 (permalink)
deepak_kr_mehta
Guest
 
Posts: n/a
confusion abt structure and class

hello sir
sir i want to resolve some confustion with u
abt struct and classes
sir in structure we can explicitly combine data structure and their behaviour and also in class, we can implement a object class which consist data structure and behaviour then diffrence is no left like
Code:
#include<iostream.h>
#include<conio.h>
    struct student
   {
   private:
  int id;  
  public:
     void set(int i)
   {
   id=i;
  }
  int get()
  {
  return id;
 }
};
class hello
{
private:
int x;
public:
void set(int i){ x=i ;}
void display(){
cout<<x;
}
};
   void main()
   {
  int c;
  student s1;
hello h1;
  s1.set(6);
h1.set(9);
h1.dispaly();
  c=s1.get();
  cout<<c;
  getch();
}
  Reply With Quote
Old 05-14-2005, 09:10 AM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
In C++ both a struct and a class have the same memory model. So the only difference is their default access specifiers (public for struct, private for class).
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class using a specific instance of another class? is this possible? abs Standard C, C++ 5 02-08-2005 04:12 PM


All times are GMT -8. The time now is 07:53 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting