|
Check the machine name u provided in OpenSCManager before Create Service()
never say die
-- modified at 0:56 Tuesday 6th June, 2006
|
|
|
|
|
double convert_to_f(double c) {
return (c * 1.8) + 32;
}
double convert_to_c(double f) {
return (f - 32) / 1.8;
}
is that what you're looking for ??
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
This is what I'm trying to use now. I get a declaration syntax error. The complier is old. Turbo C++.
thanks for the time again.
#include <iostream.h>
void convert_to_f()
void convert_to_c()
int main()
{
int temp, fahr, cel, f_out, yes, no, choice, c_out;
do
{
cout<<"Please choose one of the following conversions\n";
cout<<"1 - Celcius to Fahrenheit.\n";
cout<<"2 - Fahrenheit to Celcius.\n";
cout<<"Please select at this time: ";
cin>>temp;
switch(temp)
{ case 1:
void convert_to_f()
break;
case 2:
void convert_to_c()
break;
default:
cout<<"Invalid choice.";
break;
}
cout<<"\nWould you like to recalculate another temperature? '1' for yes, '0' for no: ";
cin>>choice;
}
while(choice==1);
return 0;
}
//function begins
void convert_to_f()
{
cout<<"You choose Celcius to Fahrenheit.\n";
cout<<"Please enter the degrees in Celcius: ";
cin>>cel;
f_out = (cel * 1.8) + 32;
cout<<"The degrees converted into Fahrenheit is "<<f_out<<".";
}
//end function
//new function
void conver_to_c()
{
cout<<"You choose Fahrenheit to Celcius.\n";
cout<<"Please enter the degrees in Fahrenheit: ";
cin>>fahr;
c_out = (fahr - 32) / 1.8;
cout<<"The degrees converted into Celcius is "<<c_out<<".";
}
//end function
|
|
|
|
|
|
You would call them just like you would any other function.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
As i'm sure you can tell, i'm a beginner writer. so i'm not sure how to do it.
|
|
|
|
|
|
selfish man (
i hate people that ask a question and who delete their question once they have the answer.
this is totally selfish behavior, and doesn't encourage to answer much to guys like you
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
I'm very sorry, as much as i am new with c++ language, i am new to the forums. I thought that if i deleted the question it would delete everything because it seems like you were getting fed up replying. again i'm sorry sir, and thank you for the help.
|
|
|
|
|
klutez123 wrote: because it seems like you were getting fed up replying
if i was, i wouldn't have answered your request
klutez123 wrote: again i'm sorry sir, and thank you for the help.
nevermind. i hope it was helpful at least, so that you solved your problem.
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
toxcct wrote:
this is totally selfish behavior, and doesn't encourage to answer much to guys like you
Mee too!, I strongly support your case!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
klutez123 wrote: void convert_to_f()
void convert_to_c()
These two statements (i.e., prototypes) are missing semicolons.
klutez123 wrote: switch(temp)
{ case 1:
void convert_to_f()
break;
case 2:
void convert_to_c()
When calling the functions, omit the void keyword, and add a semicolon.
klutez123 wrote: cin>>cel;
f_out = (cel * 1.8) + 32;
The variables cel and f_out have not been declared in the context of convert_to_f() .
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hi all,
Consider this class
(unit1. h)
<code>class MyClass{
public:
MyClass(){};
MyClass(int nNum): m_nNum(nNum){}
~MyClass(){};
private:
int m_nNum;
};</code>
in the main program
<code>
#include"unit1.h"
int main()
{
MyClass myObject(300);
}</code>
The question how many ways to modify the property (myObject.m_nNum) to another number without using setters or friends?
|
|
|
|
|
|
toxcct wrote: sorry, i don't understand your question after the sample.
may you please rephrase it ?
My question is how many ways can you later modify myObject.m_nNum to a different value
By doing it:
- Outside the class without using friends
- Ingeneous ways to do it inside the class without using a setter method
I hope that is clearer Tox!
|
|
|
|
|
if the member is public, then any function can change it
if the member is protected, only the member functions of the class + children classes + friend functions can change it.
if the member is private, then only member functions are allowed to access it.
that way, you can do whatever you want. a setter is a kind of member function which only goal is to writea field with its parameter, performing if needed a validation check on the parameter before overwriting the data member.
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
toxcct wrote: if the member is public, then any function can change it
if the member is protected, only the member functions of the class + children classes + friend functions can change it.
if the member is private, then only member functions are allowed to access it.
I know that, hence I deliberately placed it in the private section
SaRath C wrote: let me ask one question. if we do so, then what is the meaning of data sexurity in C++?
This is a hypothetical question to see what answers the forum comes up with.
-- modified at 9:17 Monday 5th June, 2006
|
|
|
|
|
anyway its cracking me.
let me ask one question. if we do so, then what is the meaning of data sexurity in C++?
SaRath.
"Don't Do Different things... Do Things Differently..."
|
|
|
|
|
You can add to the total number of ways the following unusual one:
*(int*)myObject = 400;
(This is because the MyClass class does not have virtual functions, and m_nNum is the first and only member).
|
|
|
|
|
Viorel. wrote: You can add to the total number of ways the following unusual one:
Good, I want more.
|
|
|
|
|
A similar unusual way is:
int x = 400;
memcpy(&myObject, &x, sizeof(x));
One more way:
class MyClass2
{
public:
int m_nNum;
};
MyClass2 & myObject2 = (MyClass2&)myObject;
myObject2.m_nNum = 400;
|
|
|
|
|
Viorel. wrote: public:
int m_nNum;
};
//
// in main:
//
MyClass2 & myObject2 = (MyClass2&)myObject;
myObject2.m_nNum = 400;
I will prefer get and set function rather that public variable outside the class
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
i hope you understand how bad the answers to you question can be, because of bad programming practices...
this is the only reason why i didn't answered you with such code sample, because i advise you seriously to never use such samples in your code...
security reason is always the best
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Im not sure my answer is correct or not.
we can change the attribute value by following methods
1. Set value inside the destructor
2. Through a Member pointer
SaRath.
"Don't Do Different things... Do Things Differently..."
|
|
|
|
|
SaRath C wrote: 1. Set value inside the destructor
If i set the value inside the destrutor, then how that value will be persist!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|