Click here to Skip to main content
16,004,944 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: deriving a non-template class from a template class Pin
Californian226-Dec-07 15:59
Californian226-Dec-07 15:59 
GeneralRe: deriving a non-template class from a template class Pin
Sarath C26-Dec-07 16:04
Sarath C26-Dec-07 16:04 
GeneralRe: deriving a non-template class from a template class Pin
Californian227-Dec-07 8:56
Californian227-Dec-07 8:56 
QuestionRe: deriving a non-template class from a template class Pin
Californian226-Dec-07 14:39
Californian226-Dec-07 14:39 
NewsRe: deriving a non-template class from a template class Pin
Californian227-Dec-07 8:51
Californian227-Dec-07 8:51 
GeneralWNetAddConnection returning 487 Pin
Still learning how to code26-Dec-07 10:20
Still learning how to code26-Dec-07 10:20 
AnswerRe: WNetAddConnection returning 487 Pin
Still learning how to code26-Dec-07 11:53
Still learning how to code26-Dec-07 11:53 
Generala very wierd problem Pin
gizmokaka26-Dec-07 10:14
gizmokaka26-Dec-07 10:14 
Hello to all, Sorry for posting such question here but couldn't find any more suitable place on
CodeProject, and I have no intention of posting to any other forum!!!!!!!!

the problem is as follows.
I have an application to calculate the results of a square polynom:

#include<iostream.h>
#include<math.h>

//-->Version 1
void equall(int a,int b,int c)
{
	float x1;
	x1=(-b/(2*a));
	cout<<"there is only one root and it's: x1="<<x1<<".\n";
}
//-->Version 2
void equall(int a,int b,int c)
{
	float x1, delta;
	delta=0;
	x1= (-b+delta)/(2*a);
	cout<<"there is only one root and it's: x1="<<x1<<".\n";
}

void bigger(int a,int b,int c)
{
	float x1,x2,delta;
	delta=sqrt((b*b)-(4*a*c));
	x1=(-b-delta)/(2*a);
	x2=(-b+delta)/(2*a);
	cout<<"the two roots are x1="<<x1<<" and x2="<<x2<<".\n";
}

void main()
{
	int a,b,c;
	float delta;
	cout<<"enter 3 variables (a,b,c) for the square equation: (the integer of the number is the one that counts) ";
	cin>>a>>b>>c;
	delta=((b*b)-(4*a*c));
	if(delta<0)
		cout<<"the square roots,x1 and x2,doesn't exist!\n";
	if(delta==0)
		equall(a,b,c);
	if(delta>0)
		bigger(a,b,c);
}
</math.h></iostream.h>


So it's like that, if I use version 1 x1 always gets a value of 0 no metter what I put
into a, b, c. this is of course not correct!!!

if I use version 2 it's acting OK.

this behavior is weird to me, I can't seem to understand what is it deriving from.
GeneralRe: a very wierd problem [modified] Pin
Californian226-Dec-07 10:40
Californian226-Dec-07 10:40 
GeneralRe: a very wierd problem Pin
gizmokaka26-Dec-07 11:20
gizmokaka26-Dec-07 11:20 
GeneralRe: a very wierd problem Pin
Californian226-Dec-07 11:33
Californian226-Dec-07 11:33 
GeneralRe: a very wierd problem Pin
CPallini26-Dec-07 22:22
mveCPallini26-Dec-07 22:22 
GeneralRe: a very wierd problem Pin
Luc Pattyn26-Dec-07 16:41
sitebuilderLuc Pattyn26-Dec-07 16:41 
GeneralRe: a very wierd problem Pin
David Crow27-Dec-07 4:28
David Crow27-Dec-07 4:28 
GeneralReceiving data from ListBox in another program. Pin
int01h26-Dec-07 9:31
int01h26-Dec-07 9:31 
GeneralRe: Receiving data from ListBox in another program. Pin
CPallini26-Dec-07 10:55
mveCPallini26-Dec-07 10:55 
GeneralRe: Receiving data from ListBox in another program. Pin
Hamid_RT28-Dec-07 5:07
Hamid_RT28-Dec-07 5:07 
GeneralWhy it is not good code for constructor Pin
George_George26-Dec-07 3:09
George_George26-Dec-07 3:09 
GeneralRe: Why it is not good code for constructor Pin
CPallini26-Dec-07 3:29
mveCPallini26-Dec-07 3:29 
GeneralRe: Why it is not good code for constructor Pin
George_George26-Dec-07 3:50
George_George26-Dec-07 3:50 
GeneralRe: Why it is not good code for constructor Pin
Sarath C26-Dec-07 4:09
Sarath C26-Dec-07 4:09 
GeneralRe: Why it is not good code for constructor Pin
George_George26-Dec-07 18:19
George_George26-Dec-07 18:19 
GeneralRe: Why it is not good code for constructor Pin
CPallini26-Dec-07 4:46
mveCPallini26-Dec-07 4:46 
GeneralRe: Why it is not good code for constructor Pin
George_George26-Dec-07 18:22
George_George26-Dec-07 18:22 
GeneralRe: Why it is not good code for constructor Pin
CPallini26-Dec-07 21:05
mveCPallini26-Dec-07 21:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.