|
rose aashii wrote:
i jst want u to chk my code that is giving sme errorz
What errors? Compiler, linker, run-time, assertion, exception, etc. Have you single-stepped through each line of code to see where you get unexpected results?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
You need to put the operator functions as member functions of the class (so first parameter of the function will be implicitly the this parameter). And you'll have to remove the * in the definitions of these function (return an int not a int* ).
You have luck that I'm in a good mood. Honnestly your post only deserve a 1. There is no specific question, you just want us to go through your code without giving us the errors, there is no formatting, you just made a copy paste of your homework and you don't even have the respect to use correct english. It is a forum here, not a mobile so avoid using SMS language
|
|
|
|
|
rose aashii wrote:
int *operator +(math m)
{
number = number + m.number;
return number;
}
ok, i'll not repeat what cedric already told you, but if you think a liitle on your code, you could see this :
you return an int* .
firstly, we use to return references instead of pointers when coding operators overloads.
secondly, do you really want here to modify the value of the operands ?
if you consider the operation : 2 + 2 , i should return 4, but not modify none. moreover, which part would you modify here ? 2 (non l-value) ?!
so, just return an int ...
and don't forget !!! reflection is the begining of a good code ! ;P
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
i won't give you the entiere solution (as homeworks are for grow up self knowledge), but i give you a start point by designing a good class (i changed the class name into CMathCalc to avoid redefining a supposed existing math identifier) :
MathCalc.h
<font color=blue>class</font> CMathCalc {
<font color=blue>double</font> m_Data;
<font color=blue>public</font>:
<font color=green>
CMathCalc();
CMathCalc(<font color=blue>double</font>);
<font color=blue>virtual</font> ~CMathCalc();
<font color=green>
<font color=blue>double</font> Display() <font color=blue>const</font>;
<font color=green>
<font color=blue>double operator</font> + (<font color=blue>double</font>) <font color=blue>const</font>;
<font color=blue>double operator</font> - (<font color=blue>double</font>) <font color=blue>const</font>;
<font color=blue>double operator</font> * (<font color=blue>double</font>) <font color=blue>const</font>;
CMathCalc& <font color=blue>operator</font> = (<font color=blue>double</font>);
CMathCalc& <font color=blue>operator</font> = (<font color=blue>const</font> CMathCalc&);
<font color=blue>double</font> <font color=blue>operator</font> + (<font color=blue>const</font> CMathCalc&) <font color=blue>const</font>;
<font color=blue>double</font> <font color=blue>operator</font> - (<font color=blue>const</font> CMathCalc&) <font color=blue>const</font>;
<font color=blue>double</font> <font color=blue>operator</font> * (<font color=blue>const</font> CMathCalc&) <font color=blue>const</font>;
<font color=blue>friend double operator</font> + (<font color=blue>double</font>, <font color=blue>const</font> CMathCalc&);
<font color=blue>friend double operator</font> - (<font color=blue>double</font>, <font color=blue>const</font> CMathCalc&);
<font color=blue>friend double operator</font> * (<font color=blue>double</font>, <font color=blue>const</font> CMathCalc&);
};
<font color=green>
<font color=blue>double operator</font> + (<font color=blue>double</font>, <font color=blue>const</font> CMathCalc&);
<font color=blue>double operator</font> - (<font color=blue>double</font>, <font color=blue>const</font> CMathCalc&);
<font color=blue>double operator</font> * (<font color=blue>double</font>, <font color=blue>const</font> CMathCalc&);
ok, i think you have enough information now to have a good mark...
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Wow, you are so patient today
|
|
|
|
|
|
toxcct wrote:
bored with my project
Which Project
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
i'm currently making an application for a ski rent shop with oracle designer/forms...
quite indigest...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
The kind of things I hate to do...
|
|
|
|
|
cedric moonen wrote:
The kind of things I hate to do...
Me TOO, It's Obvious, VC++ programmer and DATABASE
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi this is pratap
i am working on datawarehousing tool implemented in VC
I am Implementing oledb connections in the tool.
For this i am using the classes CDataSource, CSession,CTables,CColumns,CPrimaryKeys, CForeignKeys etc.
every thing i am getting fine except the column properties like column length,precision, datatype name etc. can any one help in this.
expecting positive reply
thank you
pratap
|
|
|
|
|
Hi,
I have used the following codes to load a bitmap onto the dialog box for the background during onPaint.However I need to change the picture when i click another button. Is there a function which i can call to redraw the bitmap again? cos when i put these code into a function, it doesnt work.
Any idea?
[code]
CDC BmpDc;
CPaintDC dc(this);
VERIFY( BmpDc.CreateCompatibleDC(&dc) );
CBitmap BkBmp, *pOldBmp;
//BkBmp.
BkBmp.LoadBitmap(IDB_background);
pOldBmp = (CBitmap *)BmpDc.SelectObject(&BkBmp);
dc.BitBlt(0,0,m_nW,m_nH,&BmpDc,0,0,SRCCOPY);
BmpDc.SelectObject(pOldBmp);
[/code]
Newb VCer
|
|
|
|
|
If OnPaint() takes the bitmap ID from a member variable and paints it, your button handler might simply change the ID of the bitmap to draw and invalidate the window. Something like this:
<br />
m_BackBitmapID = IDB_Background1;<br />
<br />
Invalidate(); <br />
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
|
Are there any codes out there that helps me to estimate or calculate the center of a sphere from a set of data points on the surface of the sphere? for eg., least-squares fitting of a set of points to the equation of a sphere?
THANKS!
|
|
|
|
|
mm don't know any code but if I'm not mistaken the radius is in the equation correct?
this means you have the distance of each point on the sphere to the center.
take to points and calculate which point is on distance = radius to the two known points.
If you don't know your formulas, search the net. you need the equation of the sphere and the equations for calculating the distances. (Don't know it by heart sorry, it 's something with roots and power to two etc)
good luck.
No hurries, no worries.
|
|
|
|
|
At first I tried to remember 3D math, surface equations and surface normals
But solution is easy if I do not misunderstand
You have limited sample points (x,y,z) of a sphere.
Search all samples and obtain Minimim and Maximum value of X,Y,Z;
The center of the sphere is (Xcenter,Ycenter,Zcenter)
The equation should be so;
Xcenter = (Xmin + Xmax) / 2
Ycenter = (Ymin + Ymax) / 2
Zcenter = (Zmin + Zmax) / 2
I hope it helps you
|
|
|
|
|
Or you can apply clasiccal method;
You should have at least three surface point to obtain a sphere.
(Xo,Yo,Zo) is center coordiane of sphere and r is half of diameter
Sphere equation is
(X - Xo)^2 + (Y - Yo)^2 + (Z - Zo)^2 = r^2
We have 3-samples
Sample1 : (X1,Y1,Z1)
Sample2 : (X2,Y2,Z2)
Sample3 : (X3,Y3,Z3)
Place these three sample to the above equation, and then you will obtain 3 equation with unknown Xo,Yo,Zo parameters. You can easily calculate these with three equation.
|
|
|
|
|
I just wrote a toolband code to create a toolbar...when i compiled that, the new browser created has the title corrupted..Do any body know abt this..
Replies will be appreciated...(Eg: if the title of the page is "about blank" only "a" comes there....)
Thanx in Advance..
|
|
|
|
|
SunSelvaS wrote:
(Eg: if the title of the page is "about blank" only "a" comes there....)
Just a wild guess but...
Whenever I see only the first char of a string being displayed, it always make me think of a UNICODE/ANSI mismatch problem. Any chance you are passing a unicode string (WCHAR) to something that takes it as ANSI (char)?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Try to modifying the resource string for this title id and check.
if u r using some toolkit for GUI( Xp style) then its worth checking the resource table.
Lokiz
|
|
|
|
|
alok... i deleted all the .ncb(not .ncw) file.. and now the code assistant is working..great man.. thanks a lot.. but still the "Symbol not defined" is displayed when u right click on a variable to see where it is declared... can u help me out ?
vivek
|
|
|
|
|
that too the variables are declared only in the header file.. not in the cpp file..
vivek
|
|
|
|
|
Go into Project->Settings->C/C++->[Category:Listing Files] and check the "Generate browse info" checkbox, then recompile all.
~RaGE();
|
|
|
|
|
Rage()
{
strcpy(ERROR,"ITS STILL NOT WORKING!");
}
..
vivek
|
|
|
|