|
INTERVIEW QUESTIONS
C++
C++ BASICS
DETAILS
Question: Define a class named cord, a point in Cartesian coordinate system where each point has two int type values x and y. Your class must contain necessary constructors and arithmetic operator functions. Write necessary codes to test your class?
Answer: class cord { private : int x,y; public: cord() { x=y=0; } cord(int &a,int &b) { this->x=a; this->y=b; } friend void add(cord&a,cord&b) { float dis; cord c; //if((a.x>b.x)&&(a.y>b.y)) c.x=a.x-b.x; c.y=a.y-b.y; dis=sqrt(((c.x*c.x)+(c.y*c.y))); cout<<dis<<endl; };
|
|
|
Category |
C++ Basics Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9375 users |
Added on |
11/22/2013 |
Views |
68538 |
Rate it! |
|
|
Question:
Define a class named cord, a point in Cartesian coordinate system where each point has two int type values x and y. Your class must contain necessary constructors and arithmetic operator functions. Write necessary codes to test your class?
Answer:
class cord { private : int x,y; public: cord() { x=y=0; } cord(int &a,int &b) { this->x=a; this->y=b; } friend void add(cord&a,cord&b) { float dis; cord c; //if((a.x>b.x)&&(a.y>b.y)) c.x=a.x-b.x; c.y=a.y-b.y; dis=sqrt(((c.x*c.x)+(c.y*c.y))); cout<<dis<<endl; }; Source: CoolInterview.com
Answered by: sharad kumar .j | Date: 12/3/2008
| Contact sharad kumar .j
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How do you access the static member of a class?
|
View Answer
|
|
What is a local class?
|
View Answer
|
|
What is class? What is object? Describe these 2 with example.
|
View Answer
|
|
I am a new computer engineering student can you please explain what is c++ and its uses please answer me this question as faster as you can?
|
View Answer
|
|
What is the definition of abstract class and virtual function?
|
View Answer
|
|
What is the return value for getch()?
|
View Answer
|
|
What are the major differences between C, C++, JAVA?
|
View Answer
|
|
Which type of questions are asked in interviews?
|
View Answer
|
|
what are the differences between c and c++? If possible give more points. what are the disadvantages of C++?
|
View Answer
|
|
What is Difference between c and c++?
|
View Answer
|
|
what are the differences between member function and constructor?
|
View Answer
|
|
why c++ is called as object-oriented language? Here what does object mean?
|
View Answer
|
|
what are the differences between c and c++.what are the advantages the are only in c++ but not in c
|
View Answer
|
|
The class which acts as interface between the C++ and the Java layer?
|
View Answer
|
|
What is a class?
|
View Answer
|
|
What is the difference between structures and classes in C++?
|
View Answer
|
|
What is the difference between class and structure?
|
View Answer
|
|
What is the Basic nature of "cin" and "cout" and what concept or principle we are using on those two?
|
View Answer
|
|
What is the difference between an object and a class?
|
View Answer
|
|
What is encapsulation?
|
View Answer
|