|
ok me and my friend have been working on the program and are having trouble getting the arrays to pass to the functions and dont know where the issue is.
#include <iostream>
using namespace std;
class Integer{
public:
Integer();
Integer(Integer& a);
Integer operator +(const Integer &);
Integer operator -(const Integer &);
bool operator<(Integer)const;
void SetArr();
void print();
void addNumbers();
void subNumbers();
private:
bool sign;
int size;
int size2;
int size3;
char * arr1;
char * arr2;
char * arr3;
};
int main()
{
Integer sum,diff, in1,in2;
in1.SetArr();
/*in2.SetArr();
in1.addNumbers();
in1.print();
in1.subNumbers();
in1.print();*/
}
Integer::Integer()
{
size=0;
arr1=NULL;
}
Integer::Integer(Integer& a)
{
a.size=0;
a.arr1=NULL;
}
void Integer::SetArr()
{
cout<<"How many digits is the number?"<<endl;
cin="">>size;
int* arr1=new int[size];
cout<<"Enter the sequence of the "<<size<<" integers"<<endl;=""
="" for(int="" i="(size-1);i">=0;i--)
cin>>arr1[i];
cout<<endl;
for(int="" i="0;i<size;i++)
" cout<<arr1[i];
="" cout<<endl<<"how="" many="" digits="" is="" the="" second="" number?"<<endl;
="" cin="">>size2;
int* arr2=new int[size2];
cout<<"Enter the sequence of the "<<size2<<" integers"<<endl;=""
="" for(int="" i="(size2-1);i">=0;i--)
cin>>arr2[i];
cout<<endl;
for(int="" i="0;i<size2;i++)
" cout<<arr2[i];
="" if(size="">=size2)
size3=size+1;
else
size3=size2+1;
int* arr3=new int[size3];
int carry=0;
for(int i=0;i<size3;i++){
arr3[i]="48+(arr1[i]+arr2[i]-2*48+carry)%10;
" carry="(arr1[i]+arr2[i]-2*48+carry)/10;
" }
="" cout<<endl<<"addition:"<<endl;
="" for(int="" i="(size3-1);i">=0;i--)
cout<<arr3[i];
="" cout<<endl<<endl;
=""
="" for(int="" i="0;i<size3;i++){
" if(arr1[i]="">arr2[i])
arr3[i]=arr1[i]-arr2[i];
else{
arr1[i+1]=(arr1[i+1]-1);
arr1[i]=arr1[i]+10;
arr3[i]=arr1[i]-arr2[i];
}
}
cout<<endl;
for(int="" i="0;i<size3;i++)
" cout<<arr3[i];
="" cout<<endl<<"subtraction:"<<endl;
="">=0;i--)
cout<<arr3[i];
}
void integer::print()
{
="" for(int="" i="0;i<size;i++)
" cout<<arr1[i];
}
void="" integer::addnumbers()
{
="" int="" carry="0;
" arr3[i]="48+(arr1[i]+arr2[i]-2*48+carry)%10;
" }
}
void="" integer::subnumbers()
{
="" if(arr1[i]="">arr2[i])
arr3[i]=arr1[i]-arr2[i];
else{
arr1[i+1]=(arr1[i+1]-1);
arr1[i]=arr1[i]+10;
arr3[i]=arr1[i]-arr2[i];
}
}
}
|
|
|
|
|
Use code tags when you post code.
Focus on the class - not the input/output. For testing you can hard code some values right now.
|
|
|
|
|
HOW CAN I CREATE A TRAPEZIUM WITH A CIRCLE INSIDE IT??(CODE)
|
|
|
|
|
Why are you screaming at the people when you are asking for help?
You might look at using a graphics library to draw graphics objects....
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
We assumed it would be through code. If you're just talking about drawing it on paper, then you've come to the wrong place.
For the trapezium, draw a polygon. For the circle, draw an ellipse. Use maths to work out where to position each.
|
|
|
|
|
Hi,
I need a notification mechanism for windows shutting down prefferably wthout polling.
Any ideas?
Thanks in advance.
Sunil
|
|
|
|
|
WM_QUERYENDSESSION [^] may be the message you need to check.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Some dimwit had downvoted you for giving a valid answer.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Rajesh R Subramanian wrote: Some dimwit Extremely dim, I think. Thanks, your 40 points take me soaring to the sky again.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
And another counter.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
Thanks, maybe my stalker is back from holiday, or jail.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Sunil
|
|
|
|
|
Hi,
i have two classes, and i am trying to use the ternary operator in the initializer list to initialize Class2 memeber to some value or null based on the data in MyClass2 constructor:
MyClass
{
...
int x;
int y;
}
MyClass2
{
...
MyClass myObj;
}
MyClass2 Constructor:
Version 1)
MyClass2(const AnotherClass* data) :
myObj(data ? data->x : MyClass()) --compile error
Version 2)
MyClass2(const AnotherClass* data) :
myObj(data ? data->x : MyClass my) --synatax error
I get the following error: error: no match for ternary 'operator?:' in ...
How could i fix this?
Thanks
|
|
|
|
|
Just put it into the the ctor body
MyClass2(const AnotherClass* data)
{
if (data)
myObj = data->x;
}
|
|
|
|
|
Your ternary expression makes no sense; if true it returns an integer, and if false it returns an object.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
hi, i'm chacha..
i have a trouble creating voic applications to image and from image to sound using C++
I asked for help and sample code,,please
|
|
|
|
|
First off, I dont undertand what you mean. Second; you should try something out before posting a question. This would make things clear to you and to the rest of us what you are trying to achieve, as iut is now, i doubt you would get any usful replies.
|
|
|
|
|
i want making the speech recognition application using c++,,please help me give pieces of programs(source code)or articles that can me make reference ? thx
|
|
|
|
|
Two possibilities.
1. Your question needs to be re-phrased.
2. What you are requesting is beyond your abilities, and in general beyond the ability of anyone (or groups for that matter.)
|
|
|
|
|
i want making the speech recognition application using c++,,please help me give pieces of programs(source code)or articles that can me make reference ? thx
|
|
|
|
|
Develop MS Excel related Number and Logical functions. means develop another application like MS excel in c++.. suggest me
|
|
|
|
|
You have already asked this vague question in QA.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
You might want to hire this guy[^] to get you started.
|
|
|
|
|
I tried to download and install the patch for the microsoft foundation classes fo Visual c++ express 2010 but can not seem to make it work
|
|
|
|
|
Okay... you might try asking in the MFC forum, here[^]. This is the Mangaged C++ forum. And when you ask there, you might consider including more information. "can not seem to make it work" is not a very helpful description of your problem.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|