|
Thats true, in C things will not happen by itself.
It's also very true that a lot of C++ programmers have bad habits, but the language doesn't change it. For every language are programmers that have bad habits. I C# for example, some people think that they can allocate and copy objects all they want and let the garbage collector take care of of it. They don't know that this "style" has a huge affect on performance.
John R. Shaw wrote:
That's why I would recommend, after learning the basics and reading Bajarne Stroustrups Book, reading the puzzle books by Herb Sutter.
Those books are also great. I have a few of them myself on the bookshelf.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello,
Since you are not in college yet, you mind find the C++ book by bjarne stroustrup a little bit hard to understand. IMO, it's not the best place to start if you are not familliar with the technical level in the book. Things are explained that are hard to grasp, especially for people who don't know C++ yet.
I think that you should start out simple. Rent a book for "dummies" somewhere in a library and get familiar with the syntax, memory management, OO and containers. After that you should be ready for the more advanced books. The book suggested by Cristian is a really good book about C++. Some other authors names: meyers, ellis. I didn't read books written by them, but they are fererenced in many other books.
Good luck with your studies!
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
If you become good in C++, you will become a good programmer. A programmer which understands the underlying mechanisms.
I'm not saying you won't become a good programmer if you choose, let's say C# for instance. But if you learn a complex and complete language such as C++, it's quite easy to learn other languages. That's my experience.
Good music: In my rosary[^]
|
|
|
|
|
Hi everyone,
I'm trying to check if a page was loaded correctly into my class extending CHtmlView. I mean I want to check if the page was found. And only a way I can think of is to check status codes of a server response.
I have found OnNavigationError function in CHtmlView whuch check the codes. But it looks like it's defeined in MFC 7. I use 6th one.
Are there any ways to get status codes for any MFC classes like CHtmlView? I do not want to work with sockets directly. But if there is no way to avoid it how can i get a pointer to a socket used in my instance of CHtmlView?
Thanks in advance.
Rotciv
|
|
|
|
|
vicel wrote:
I'm trying to check if a page was loaded correctly into my class extending CHtmlView.
What about the GetReadyState() or GetBusy() methods?
vicel wrote:
I have found OnNavigationError function in CHtmlView whuch check the codes. But it looks like it's defeined in MFC 7. I use 6th one.
What about the OnDownloadComplete() method?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
These functions are different from what I need. They show up page loading process.
If a page was not found a server can return just a header with status code = 404 (page not found) and then OnDownloadComplete should say that download failed. Or it can return (!) an error page. So a page will be downloaded anyways.
That's why I want to see status codes.
|
|
|
|
|
I have such code:
<br />
System::Windows::Forms::Form * form1 = new error;
form1->Controls->Add(listbox);
form1->Show();<br />
When I try to build project, it returns error c2061 on the string(marked in code). What should I do?
|
|
|
|
|
fenixk19 wrote:
What should I do?
You could start by posting the error message itself, it usually gives a very good clue as to which identifier the complier did not recognize. You could also look up C2061 in MSDN to get a description of the error, as well as the recommended solution.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
|
Error message
d:\Documents and Settings\Phoenix\Мои документы\My_app\autonapominalka\main.cpp(138): error C2061: syntax error : identifier 'form1'
I've already looked up in MSDN. I won't be there if i found solution in MSDN.
listbox:
System::Windows::Forms::ListBox * listbox = new ListBox;
listbox->BackColor = System::Drawing::SystemColors::Control;
listbox->Location = System::Drawing::Point(96, 8);
listbox->Name = S"listBox1";
listbox->Size = System::Drawing::Size(208, 56);
listbox->TabIndex = 2;
PS Sorry for my English
|
|
|
|
|
Hello everyone
I want to write an application in c++, I have got visual studio.net which includes c++.net. Somebody told me that application developed in .net framework is compiled in-time. So it's slow. But application developed in c++ is compiled, it's quicker. Visual studio.net contains c++.net aswell. So could anybody give me an idea what's the difference between v++ and c++.net please??? And what's the exactly meaning of the win32 project? What's the difference between win32 project and the windows form application project???
Another question is that if I make an application in c++ using mysql as my database. How can I make a connection to the source database please???
Thanks in advance!!!
Asura
|
|
|
|
|
Ming Luo wrote:
Somebody told me that application developed in .net framework is compiled in-time. So it's slow. But application developed in c++ is compiled, it's quicker.
This is only partly correct. Once the .Net framework has been loaded, the differences in speed are negligible.
Ming Luo wrote:
So could anybody give me an idea what's the difference between v++ and c++.net please???
See here, here, and here.
Ming Luo wrote:
Another question is that if I make an application in c++ using mysql as my database. How can I make a connection to the source database please???
If you are using MFC, check out the CRecordset and CDatabase classes. Otherwise, you can use the ODBC API directly.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
A C++ app is only 'slower' if you use managed c++, otherwise, it's the same as any C++ compiler.
Ming Luo wrote:
And what's the exactly meaning of the win32 project? What's the difference between win32 project and the windows form application project???
Windows Forms is managed C++, it's slower, and more complex to use in C++. Win32 is a console app, or a non MFC C++ app. An MFC app is probably what you want.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am a quite new C++ learner. Could you tell me what's the exactly meaning of managed C++ please? And how can I avoid using managed C++???
Thanks
Asura
|
|
|
|
|
Managed c++ is c++ with added keywords to use the .NET framework. If you create MFC applications with the form wizard, they should be unmanaged by default. In any case, if you don't use the .NET framework, I doubt that having a MC++ app will hurt, it will just sit there, unused.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm using MS Hierarchical FlexGrid to display hierarchical data from a database in a grid. As of now, I can't find out how to do that. I'm using Microsoft Visual C++ .NET 2003. I want to display data from two tables. One table has primary information, and the second table has multiple records for each record in the primary table. I'd like to display just the primary information and just let the user highlight a record to see what records in the second table belong to it. If anybody knows how to use the MSHFlexGrid (mshflxgrd.ocx... as opposed to the non-hierarchical one msflxgrd.ocx) and could offer any help, that'd be appreciated. Or if anybody knows how to solve this problem without mshflexgrid, that'd be great as well.
|
|
|
|
|
May I know how I can access map by index just like I access vector by index?
cout<< "This is the 10th element (0 based) in my vector = "<< myVector[10];
For map, when I wish to access the 10th element (0 based), I would do the following:
map<char *,="" int="">::iterator curr, end;
end = myMap.end();
curr = myMap.begin();
for(int i=0; i<10; i++) {
curr++;
}
cout<< "This is the 10th element (0 based) in my map = "<< myMap->second;
I was wondering whether is there any better way other than having to loop through all the items? For example:
/* The following code is just a wish, it is not valid. */
cout<< "This is the 10th element (0 based) in my vector = "<< myMap.getItemByIndex(10);
Thank you.
cheok
|
|
|
|
|
std::map is not a random access container, you cannot access a item directly like you can do for std::vector.
Me think that accessing an indexed element of a map ( i.e. the 10th element ) is not usefull.
AFAIK, looping maps like you do will work.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
You can but there could be a high price to pay performance-wise depending our the std::map implementation you are using:
#include <map>
#include <string>
#include <iostream>
void main( )
{
typedef std::map<int, std::string> Numbers;
Numbers n;
n.insert(Numbers::value_type(1,"one"));
n.insert(Numbers::value_type(2,"two"));
n.insert(Numbers::value_type(3,"three"));
Numbers::iterator iCurrent = n.begin();
// You can use the 0-based index of the element to access
// This is not an efficient way to access element of map
// and there is no out-of-boundary validation. You have
// been warned!
std::advance(iCurrent, 1);
std::cout << (iCurrent->second).c_str() << std::endl;
}
A better approach would probably be to store your data in a std::vector, the sort it with std::sort. This way you can use std::find to achieve logarithmic access time as per std::map or instant access time with std::vector's operator[].
Good luck,
g.
|
|
|
|
|
Hello,
the std::map container is not designed for array indexed access. If you need this, you probably chose the wrong container.
You can however copy the contents of the map to a vector and access it from there:
std::vector<int> vec;
vec.insert(yourmap.begin(), yourmap.end());
int i = vec[1];
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Itr to edit a record of a table which it has fields of type float.
When these fields have decimals the update cannot be done. But when they are without decimals the update is successful.
Does anyone know how can I update the record even if it has fields with decimals?
Thanks in Advance
|
|
|
|
|
Without seeing a relevant code snippet, it's hard to say what you are doing wrong.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
double value=15.1
TableSet->Open();
TableSet->MoveFirst();
while(!TableSet->IsEOF()) {
if(TableSet->m_field1 == id) {
TableSet->Edit();
TableSet->m_field2 += value;
TableSet->Update();
} else {
TableSet->MoveNext();
}
}
When TableSet->m_field2, which is of type float, has decimals the update return error.
When it does not have decimals no error occurs.
Any idea?
|
|
|
|
|
sirtimid wrote:
...the update return error.
And what would that error be?
What does the DoFieldExchange() method look like for the CRecordset -derived class?
Is the corresponding field in the database table a floating-point type?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Is it correct in anyway to declare a same variable (variable type and name same) multiple times in Visual C++ code of single block ?
For example,
void Function( int i, int j )
{
HRESULT hr = E_FAIL;
.
.
.
HRESULT hr = CComObject::GetInterface(...);
.
.
}
Appreciate answers and suggestions. Thanks in advance.
|
|
|
|