|
Thanks, i'll try to look through the links.
|
|
|
|
|
i have a rowset to be update,insert,delete, and i want to known all modify infomation about the rowset,Is ole db or odbc support this?
or any idea else?
thank you!
i am realfly8)
|
|
|
|
|
|
I'm learning about vector STL containers, is this also considered an array?
|
|
|
|
|
No. But it can do many of the same types of things that an array can, and a bit more. Vectors are dynamic arrays, in that they can grow as you add elements to them. They are similar to arrays in that they provide the subscript operator[] (you can use standard array notation).
Use a vector if your code might throw exceptions.
Use a vector if most of your inserts will be at the back, and few near the front (otherwise consider deque or list).
Use a vector to support better initialisation.
Always prefer standard containers, list, vector, deque to arrays. less code, cleaner code, better support for copying - and in the end easier to work with.
[edit]Most vectors are internally implemented as arrays, but that shouldn't matter to the end user.[/edit]
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Andrew Walker wrote:
[edit]Most vectors are internally implemented as arrays, but that shouldn't matter to the end user.[/edit]
IIRC a vector must be implemented as an array, because &(vector[0]) is a legal expression to get a C pointer to the array. (ref. herb sutters Effective STL)
(Strings, OTOH, need not)
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
peterchen wrote:
IIRC a vector must be implemented as an array, because &(vector[0]) is a legal expression to get a C pointer to the array.
Yeah, I believe that is correct
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
That was left out of the original standard but has been (or will be) added. William would know for sure.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
yes, it want to be a safe one
i am realfly8)
|
|
|
|
|
Good explanation Andrew,
Thanks everybody.
|
|
|
|
|
please link to :http://www.my1489.ni8.net
please tell me what controls is this ,where could download it?i am very confused!help me
chinese girl
|
|
|
|
|
http://www.codeproject.com/miscctrl/TimeTestMfc.asp?target=mourad
i am realfly8)
|
|
|
|
|
thank you 1谢谢!where are you ?你在那个国家?
|
|
|
|
|
|
Ok here is the goal of the program:
Create a C++ Program that acts as a calculator for the user. The program should start off by printing, to the screen, a menu that offers the user one of five options. The menu should look somethings like this, but feel free to dress it up any way you want to make it look nice.
1.Add
2.Subtract
3.Multiply
4.Divide
5.Exit
The user wil then select one of the options. Then the program must prompt the user forthe input data and print the results to the screen. After the user has found the desired results, the menu should then reappear to allow the user to do another calculation. Do not let the user out of the program until the user has typed 5 for exit.
Rules: The program must use at least 5 functions, not including MAIN.One funtion will be for the menu and one function for each of the calculations.
Input for the program will be data that is in the integer range, and you can make the assumption that I will NOT type 0 to force a divide by 0 error ( Nice instructor eh?? . However, if the user types in a menu item number that does not appear, then the program should return the user an error message that they have typed an incorrect number and allow the user to retype a valid number.
Ok with all that said below is the source code that I have written in MS Visual C++. I am thinking I am running into problems with my functions, although I am not to sure. And thanks in advance for anyone who takes the time to offer some help.
#include <iostream>
#include <conio.h>
using namespace std;
int sum = 0;
int ssum = 0;
int msum = 0;
double dsum = 0;
int x = 0;
int y = 0;
int menu();
int c = menu();
int main()
{
do
{
int menu();
if(c == 1)
int add();
else if(c == 2)
int sub();
else if(c == 3)
int multi();
else if(c == 4)
double div();
}
getch();
return 0;
}
int menu()
{
int sel = 0;
cout<<"Please select a menu choice..."<<endl
<<"1. Add"<<endl
<<"2. Subtract"<<endl
<<"3. Multiply"<<endl
<<"4. Divide"<<endl
<<"5. Exit program"<<endl;
cin>>sel;
if(c = 5)
cout<<"Thank you for using the calculator!"<<endl;
else if(c > 5 && c < 1)
cout<<"You have entered an invalid selection!"<<endl;
return sel;
}
int add()
{
cout<<"Please enter a number..."<<endl;
cin>> x;
cout<<"Please enter your second number..."<<endl;
cin>>y;
sum = x + y;
cout<<"The answer is "<<sum<<endl;
return sum;
}
int sub()
{
cout<<"Please enter a number..."<<endl;
cin>> x;
cout<<"Please enter your second number..."<<endl;
cin>>y;
ssum = x - y;
cout<<"The answer is "<<ssum<<endl;
return ssum;
}
int multi()
{
cout<<"Please enter a number..."<<endl;
cin>> x;
cout<<"Please enter your second number..."<<endl;
cin>>y;
msum = x * y;
cout<<"The answer is "<<msum<<endl;
return msum;
}
double div()
{
cout<<"Please enter a number..."<<endl;
cin>> x;
cout<<"Please enter your second number..."<<endl;
cin>>y;
dsum = x / y;
cout<<"The answer is "<<dsum<<endl;
return dsum;
}
*Edit* Hopefully this helps now
|
|
|
|
|
Hi Fightingbee, welcome to CP. It's hard to read your code, please edit the post and either wrap your code in a <pre> block, or check the "Display this message as-is (no HTML)" box so spacing is preserved.
From a quick glance, your function calls are wrong.
int add();
is only a prototype, telling the compiler that a function add() exists and returns an int . When you want to call the function, you write
add();
--Mike--
"I'm working really, really fast at the moment, so a 3 minute outage becomes, due to time dilation, a 5 minute outage."
-- Chris Maunder, relativistic system administrator
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Well I tried pulling the int out of the int add(); and likewise functions ( when they are called and when I am defining them and the compiler threw up about 7 errors at me. So I am not sure exactly what it is I am to do.
|
|
|
|
|
Fightingbee wrote:
and the compiler threw up about 7 errors at me.
What errors did you get?
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
Well ok here is the copy of the changed code,
#include<iostream>
#include<conio.h>
using namespace std;
int sum = 0;
int ssum = 0;
int msum = 0;
double dsum = 0;
int x = 0;
int y = 0;
int menu();
int c = menu();
int main()
{
do
{
menu();
if(c == 1)
add();
else if(c == 2)
sub();
else if(c == 3)
multi();
else if(c == 4)
div();
}
while(c == 5);
cout<<"Thank you for using the calculator!"<<endl;
getch();
return 0;
}
menu()
{
int sel = 0;
cout<<"Please select a menu choice..."<<endl
<<"1. Add"<<endl
<<"2. Subtract"<<endl
<<"3. Multiply"<<endl
<<"4. Divide"<<endl
<<"5. Exit program"<<endl;
cin>>sel;
if(c > 5 && c < 1)
cout<<"You have entered an invalid selection!"<<endl;
return sel;
}
int add()
{
cout<<"Please enter a number..."<<endl;
cin>> x;
cout<<"Please enter your second number..."<<endl;
cin>>y;
sum = x + y;
cout<<"The answer is "<<sum<<endl;
return sum;
}
int sub()
{
cout<<"Please enter a number..."<<endl;
cin>> x;
cout<<"Please enter your second number..."<<endl;
cin>>y;
ssum = x - y;
cout<<"The answer is "<<ssum<<endl;
return ssum;
}
int multi()
{
cout<<"Please enter a number..."<<endl;
cin>> x;
cout<<"Please enter your second number..."<<endl;
cin>>y;
msum = x * y;
cout<<"The answer is "<<msum<<endl;
return msum;
}
double div()
{
cout<<"Please enter a number..."<<endl;
cin>> x;
cout<<"Please enter your second number..."<<endl;
cin>>y;
dsum = x / y;
cout<<"The answer is "<<dsum<<endl;
return dsum;
}
And here are the errors it is throwing up,
--------------------Configuration: assign4 - Win32 Debug--------------------
Compiling...
assign4.cpp
D:\Assignment 4\assign4.cpp(33) : error C2065: 'add' : undeclared identifier
D:\Assignment 4\assign4.cpp(35) : error C2065: 'sub' : undeclared identifier
D:\Assignment 4\assign4.cpp(37) : error C2065: 'multi' : undeclared identifier
D:\Assignment 4\assign4.cpp(39) : error C2660: 'div' : function does not take 0 parameters
D:\Assignment 4\assign4.cpp(68) : error C2373: 'add' : redefinition; different type modifiers
D:\Assignment 4\assign4.cpp(81) : error C2373: 'sub' : redefinition; different type modifiers
D:\Assignment 4\assign4.cpp(94) : error C2373: 'multi' : redefinition; different type modifiers
Error executing cl.exe.
assign4.obj - 7 error(s), 0 warning(s)
|
|
|
|
|
OK First of all you should make all of your int be double.
Whats up with your spacing anyways it's like 20 spaces for a tab.
Your making it too complicated for your self. Here is what I made when I was a beginner hopefully it will teach you something.
#include <iostream>
using namespace std;
float inputOne, inputTwo, answer;
char operator_, yn;
int main()
{
while (yn != 'n')
{
cout << "First number + - / * ^ second number\n";
cin >> inputOne >> operator_ >> inputTwo;
if (operator_ == '+')
answer = inputOne + inputTwo;
if (operator_ == '-')
answer = inputOne - inputTwo;
if (operator_ == '*')
answer = inputOne * inputTwo;
if (operator_ == '/')
{
if (inputTwo == 0)
{
cout << "Cannot divide by 0";
}
else
answer = inputOne / inputTwo;
}
if (operator_ == '^')
{
answer = inputOne;
for (int i=2; i<=inputTwo; i++)
answer = answer * inputOne;
}
cout << endl;
cout << inputOne << " " << operator_ << " ";
cout << inputTwo << " = " << answer;
cout << "\n\nSolve another? <y><n> ";
cin >> yn;
cout << "\n";
}
return 0;
}
[It is possible to represent everything in this universe by using 0 and 1]
I was born intelligent
Education ruined me!.
An idea is useless until it has been implemented.
|
|
|
|
|
How could I change the Font for the Application. For the dialogs it is easy, but for my Statusbar / Menu I didn't find any good solution by now. Could anyone help ?
|
|
|
|
|
我觉得状态栏的文字给对话框的文字一样呀!你同样可以采用在对话框中的方法
下面是我的做法:
HBRUSH CXXXX::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
/************************************************************************/
if ((nCtlColor == CTLCOLOR_STATIC ))
{
pDC->SetBkMode(TRANSPARENT);
int nID = pWnd->GetDlgCtrlID();
if( (nID == CONTROL'S ID ))
{
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkColor(TRANSPARENT);
//pDC->SetBkColor(RGB(255,255,255));
}
HBRUSH hbr = ::CreateSolidBrush(RGB(248,251,255));
return hbr;
}
// TODO: Return a different brush if the default is not desired
/************************************************************************/
return hbr;
}
|
|
|
|
|
The color of the Font is not important. The Font itself is. In this case I want to use Arial Unicode MS by default.
I don't want to change the Windows Settings for this.
|
|
|
|
|
for statusbar, use the SetFont member function.
Read mike dunn's FAQ first.
Hari Krishnan
|
|
|
|
|
I think I should explain :
I tried the SetFont some times at different location, everytime with the same result : 1. I don't change anything or 2. It change the Font to anything like default System Font. But I never got the Font I want.
I checked and tied several Onlinetuturial to change the Font in StatusBar, also the one in the MSDN (mainly thought for Bitmaps in CStatusBar). Everytime only this results. Cause I can use the Font in all my Dialogs (thanks to Visual Net, I could choose this in the Resource Editor), I thought there may be an easy way also for the MainFrame. That could help also with the title of the dialogs/windows (maybe).
Is there any help for me ?
|
|
|
|