Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
Hi. I wrote a simple program for creating and editing vector. I need the graphic user interface to it. I do not know how. The most primitive. Help me, someone.

#include <conio.h>
#include <iostream.h>

class vect {
public:
   vect(int=0,int=0,int=0,int=0,int=0);   
   vect operator+(const vect &) const;   
   vect operator-(const vect &) const;
   vect operator*(const vect &); 
   vect operator*(const int &); 
   
   void print() const;
   private:
   int a,b,c,d,e;
};
vect::vect(int a1,int b1,int c1,int d1,int e1)
{
   a = a1;
   b = b1;
   c = c1;
   d = d1;
   e = e1;
}
vect vect::operator+(const vect &operand2) const
{
   vect sum;
   sum.a = a + operand2.a;
   sum.b = b + operand2.b;
   sum.c = c + operand2.c;
   sum.d = d + operand2.d;
   sum.e = e + operand2.e;
   return sum;
}
vect vect::operator-(const vect &operand2) const
{
   vect diff;
   diff.a = a - operand2.a;
   diff.b = b - operand2.b;
   diff.c = c - operand2.c;
   diff.d = d - operand2.d;
   diff.e = e - operand2.e;
   return diff;
}
vect vect::operator*(const vect &operand2)
{
   vect proizv;
   proizv.a = a * operand2.a;
   proizv.b = b * operand2.b;
   proizv.c = c * operand2.c;
   proizv.d = d * operand2.d;
   proizv.e = e * operand2.e;
   return proizv;
}
vect vect::operator*(const int &operand2)
{
   vect proizv;
   proizv.a = a * operand2;
   proizv.b = b * operand2;
   proizv.c = c * operand2;
   proizv.d = d * operand2;
   proizv.e = e * operand2;
   return proizv;
}
void vect::print() const
{
   cout<<'('<<a<<", "<<b<<", "<<c<<", "<<d<<", "<<e<<')';
}
int main(int argc, char* argv[])
{
   vect x(5,6,7,8,9),y(4,3,2,1,7);
   vect z;
   int scl = 8;
   cout<<"\n Vector 1:   ";
   x.print();
   cout<<"\n Vector 2:   ";
   y.print();
   z = x + y;
   cout<<"\n Slozhenie:   ";
   z.print();
   z = x - y;
   cout<<"\n Vichitanie:  ";
   z.print();
   z = x * y;
   cout<<"\n Vector*Vector:   ";
   z.print();
   z = x * scl;
   cout<<"\n Scalar1:   ";
   z.print();
   z = y * scl;
   cout<<"\n Scalar2:   ";
   z.print();
   getch();
   return 0;
}
Posted
Updated 7-Sep-10 0:26am
v3
Comments
Toli Cuturicu 6-Sep-10 16:08pm    
Reason for my vote of 2
Code is not C#, Tags is C#...
cccfff777 9-Sep-10 5:07am    
The tag IS c++/gui

In this case, how to make the input of these two vectors? In my code vectors are set by default.
 
Share this answer
 
Comments
Richard MacCutchan 8-Sep-10 9:35am    
See my answer to your other question. If you do not understand how to enter data through a Windows based program then stick to console input.
See my answer to this question[^]. Visual C++ Express has ready made templates for producing simple Windows based programs.
 
Share this answer
 
Looks like some basic vector operation.

Hmmm... what about a UI where you first get two vectors into system and then ask user about the operation they want to do. Execute the selected operation internally.

Lets say, as per your code it's a vector that should have 5 integers.

For primitive type, UI design:
Vector 1: 5 textboxes that takes integer
Vector 2: 5 textboxes that takes integer
Then four buttons, one each for different operation.
Based on the button selected show the final vector on screen with some helpful text.
 
Share this answer
 
Would you mind send your code to me?

286035062@qq.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900