Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
question adout c++ 2011
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#1
1: how data and functions are not tightly bound with each other in procedral laguagess. plz give me a solid example.

2: in example char *name how we can store name within it. plz give example

3: when the object will be destroyed.

4:can we use cin function to give values to class data
Reply
#2
1. Data and functions are not tightly bound in procedural programming because data and functions are independent of each other. Data and functions are stored in separate locations of memory. While in object oriented programming, data and member functions are stored in same memory location. And we can access functions through its appropriate object.
For example:
int sum(int a, int b) {
int c;
c = a + b;
return c;
}
int main() {
int var1, var2;
var1=sum(10,20);
var2=sum(30,40);
}
Here var1 is data, through which we access the sum function. And var2 is another data, through which we access sum function also. While in object oriented we can access only member functions of a class through its object.
class student{
int rollNo;
char * name;
public:
void myFunc(){
cout<<”Welcome to my function”;
}
};
class teacher{
int id;
char * name;
public:
void information(){
cout<<”Welcome to teacher function”;
}
};
int main() {
student obj;
teacher tech;
obj.myFunc();
tech.myFunc(); //we can not access myFunc function through tech object.
}
So in object oriented programming data and its functions are tightly bound, while in procedural programming data and functions are not tightly bound.
2. char * name;
name= “ali”;
So Ali is saved in memory location which is labeled as name. Instead of Ali any name can be used.

3. When scope of object ends or when the program terminates, the object will destroy.
4. Yes we can use cin statement in class body to give values to class data.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  array project code c++ 2011 Vuhelper 0 1,286 12-10-2011, 06:32 PM
Last Post: Vuhelper
  factorial in C++ code 2011 Vuhelper 0 958 12-10-2011, 06:31 PM
Last Post: Vuhelper
  stack during function call in C++ 2011 Vuhelper 0 2,037 11-05-2011, 05:05 PM
Last Post: Vuhelper
  What is the Thing Queue? in c++ 2011 Vuhelper 0 1,792 11-05-2011, 05:02 PM
Last Post: Vuhelper
  ASCII to char conversion code in C++ 2011 Vuhelper 0 1,732 11-05-2011, 05:01 PM
Last Post: Vuhelper
  How to write a summation in a sequence? C++ 2011-12 Vuhelper 2 1,365 09-19-2011, 04:53 AM
Last Post: Xpert
  GetPixel problem in c++ 2011-12 Vuhelper 0 2,515 09-18-2011, 07:12 PM
Last Post: Vuhelper
  C++ with loop code 2011-12 Vuhelper 0 989 09-18-2011, 07:09 PM
Last Post: Vuhelper
  how can i read the last letter of a input file? 2011 Vuhelper 0 1,838 09-12-2011, 10:24 PM
Last Post: Vuhelper
  Different syntax? in c++ 2011-12 Vuhelper 0 1,771 09-12-2011, 10:22 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support