Solved

How to program ?

Posted on 2000-04-23
4
248 Views
Last Modified: 2010-04-02
Design a class called Tvcctor with two private data members x and y to represent vector of two components as follow :

the class should have a default constructor to initialize both data members to zero, a general constructor to initialize both data members to given values on declaration and a copy constructor to initialize one object from another on declarationl;

the class should also have a member function set() to assign given values to the two data members.

Declare a vector class object a with the default constructor, declare another class object b with the general constructor, and initialize a third class object c with b.

0
Comment
Question by:pooiteng
  • 2
4 Comments
 
LVL 1

Expert Comment

by:ntdragon
ID: 2742288
we don't do homework at EE
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2743093
But we can *help* you to make it. Do you have a more specific question?
0
 

Accepted Solution

by:
sambitdash earned 100 total points
ID: 2807510
class Tvcctor {
double x;
double y;
public:
Tvcctor():x(0),y(0){}
Tvcctor(double x1, double y1):x(x1),y(y1){}
Tvcctor(const Tvcctor& t):x(t.x), y(t.y){}  // Default copy
                                    // ctor could have done
                     // not a must
set(double x1, double y1){x = x1; y = y1;}
};

int main(void){
Tvcctor a;
Tvcctor b(10, 5);
Tvcctor c(b);
}
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2808012
sambitdash, you are not really helping him. Think a bit on why student get assignments. Just dumping a few lines of code will not help pooiteng in learning C++.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SendMessage fails while PostMessage works 2 122
object oriented programming on screen browser tutorial lesson 2 82
Create a path if not exists 7 87
Precision Problem in C++ 7 43
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question