|
Modern C++ Design
Exceptional C++
More Exceptional C++
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I really like the "Standard C++ Bible". It covers templates and all that specific C++ thing you want. And many good chapters about STL too!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I highly recommend Modern C++ Design by Andrei Alexandrescu.
http://www.amazon.com/exec/obidos/ASIN/0201704315/qid%3D1039303732/sr%3D11-1/ref%3Dsr%5F11%5F1/103-5795742-0356630
Kuphryn
|
|
|
|
|
|
Thanks everyone for the replies.
- monrobot13
|
|
|
|
|
Check out Scott Meyers' "Effective C++" books.
|
|
|
|
|
Hi.
In general, is it more extensible to implement core C++ datatypes in 32bits and 64bits operating system, or should you implement the OS specific datatypes? For example, under Windows you can implement a DWORD (32bits unsigned integer). A DWORD is equal to C++ unsigned long.
I would like to know what is most extensible in terms of C++ design and implementation?
Lastly, what is the point of an int datatype in 32bits and 64bits OS? In 32bits OS, an int is equal to a long.
Thanks,
Kuphryn
|
|
|
|
|
Here's what I've learned when dealing with the int and long data types in C++:
1. int was designed to be as large as what the CPU can handle most efficiently. In Win16 or Win32, int is 16 or 32 bits. in 32-bit UNIX systems int is 32 bits.
2. On 64-bit systems (Win64 or UNIX) int is also 32 bits, I guess to make it easier to port 32-bit apps.
3. long is 32 bits in Win16 and Win32, as well as 32-bit UNIX.
4. On Win64, long is also 32 bits, whereas on UNIX, it's 64 bits (which is what you'd expect, and how it's represented in .NET and Java).
So my suggestion, for the sake of simplicity and portability, stick with int -- don't use long .
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
long is ( or was ?! ) a size qualifier for the int at the time of 16bits apps. ( samething for short ).
long and short are not really types!
Alvaro Mendez wrote:
4. On Win64, long is also 32 bits, whereas on UNIX, it's 64 bits (which is what you'd expect, and how it's represented in .NET and Java).
Are you sure ? I thought the int would be "scaled" according to the CPU ?
Max.
|
|
|
|
|
Maximilien wrote:
long and short are not really types!
although everyone treats them as such. No one ever writes signed long int when long works just as well.
--Mike--
Friday's GoogleFight results: Britney Spears 2,190,000 - Erica Weichers 23
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Maximilien wrote:
Are you sure ? I thought the int would be "scaled" according to the CPU ?
No. AFAIK, int remains 32-bit on Win64.
|
|
|
|
|
I believe the 64-bit CPU's coming out of Intel are still 32 bits wide in terms of their 'native' word size, but 64 bits in terms of memory addressing. int therefore stays 32 bits in Win64.
Software Zen: delete this;
|
|
|
|
|
I wrote an app that creates a web page. Now they want to print it out. The problem comes that the settings for everyones printing is set differently, ie margins, header/footer, and if print background is selected. Is there a way to send IE the paramiters I want to print for this page? Thanks in advance.
Darroll
|
|
|
|
|
I've got a control derived from the browser. My printing code looks like this -
HRESULT hr;
BSTR header_BSTR = ::SysAllocString(L"&w&b&b&p");
VARIANT header_variant;
VariantInit(&header_variant);
V_VT(&header_variant) = VT_BSTR;
V_BSTR(&header_variant) = header_BSTR;
BSTR footer_BSTR = ::SysAllocString(L"&d &t");
VARIANT footer_variant;
VariantInit(&footer_variant);
V_VT(&footer_variant) = VT_BSTR;
V_BSTR(&footer_variant) = footer_BSTR;
long index;
SAFEARRAYBOUND parameter_array_bound[1];
SAFEARRAY *parameter_array = NULL;
parameter_array_bound[0].cElements = 2;
parameter_array_bound[0].lLbound = 0;
parameter_array = SafeArrayCreate(VT_VARIANT,1,parameter_array_bound);
index = 0;
hr = SafeArrayPutElement(parameter_array,&index,&header_variant);
index = 1;
hr = SafeArrayPutElement(parameter_array,&index,&footer_variant);
VARIANT parameter;
VariantInit(¶meter);
V_VT(¶meter) = VT_ARRAY | VT_BYREF;
V_ARRAY(¶meter) = parameter_array;
hr = _Browser->ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER,¶meter,NULL);
if (!SUCCEEDED(hr)) {
VariantClear(&header_variant);
VariantClear(&footer_variant);
if (parameter_array != NULL) {
SafeArrayDestroy(parameter_array);
}
}
This code sets the header and footer for the page and then prints it. The _Browser value points to the IWebBrowser2 interface for the control. If I remember correctly, I found this stuff in an example in the MSDN.
Software Zen: delete this;
|
|
|
|
|
With CString, we can perform an operation something like:
CString strMarks;
strMarks.Format("I got %d marks",marks);
Can we perform similar operation using std::string ??? If yes, then how ???
|
|
|
|
|
Try this:
char buffer[200] = {0};
std::string str = "";
int i = 9;
sprintf(buffer, "\n\nThis is number: %d\n\n", i);
str = buffer;
printf(str.c_str());
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Unfortunately, you can't. In concept of C++ std library you must use streams (like as stdout, stdin and etc). This method was perfectly described by Alexandrescu in his book "Modern C++...". But personally I like to use old good method as Format. And I have invented my own function. May be it will be useful for you
string_smart Format(cstr szText,...)
{
cstr szPtr=szText;
size_t lLen;
for (lLen=0;*szPtr; ++szPtr,(*szPtr=='%') ?lLen+=10:lLen++);
string_cstr strRes(++lLen);
va_list marker;
va_start( marker, szText);
while (_vsnprintf(strRes.buffer(),strRes.buffer_size()-1,szText,marker) <0 )
strRes.reserve(strRes.buffer_size()*2);
strRes.buffer()[strRes.buffer_size()-1]='\0';
strRes.recalc_len();
va_end( marker );
return strRes;
}
This function works with my class string_smart, but it is not hard to remake it for std::string
|
|
|
|
|
Yes you can, using the stringstream class:
#include <string>
#include <sstream>
ostringstream strm;
string strMarks;
strm << "I got " << marks << " marks" << ends;
strMarks = strm.str();
--Mike--
Friday's GoogleFight results: Britney Spears 2,190,000 - Erica Weichers 23
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I would just rearange it a little:
#include <string>
#include <sstream>
std::ostringstream strm;
strm << "I got " << marks << " marks" << std::ends;
std::string strMarks = strm.str();
|
|
|
|
|
How can we find the min / max values of a particular data type:
ex.. what is the minimum or maximim value, that can be represented by DWORD
|
|
|
|
|
try these:
<br />
ULONG_MAX,<br />
LONG_MAX, LONG_MIN...<br />
see limits.h in MSVC
|
|
|
|
|
Has anyone noticed the "Summary" tab in the file-properties dialogue (RMB on some file, for e.g a .doc or a .mp3)?
There are entries for things like "Title", "Category", "Comments" etc
You cannot use these items in a normal search, so my question is how to access these extra properties of a file programatically so that one could search for all files that (say) have a "Category" of "BACKUP:OK" for e.g.
It's like the file-system is a Table in Access and these are 'fields' but you can't use them for filtering properly.
Hope there is some idea out there!
Bats
;}
|
|
|
|
|
http://support.microsoft.com/default.aspx?scid=KB;en-us;q186898
|
|
|
|
|
Thanks for the link - I am looking at it now !
Bats
:}
|
|
|
|
|
Ok - compiled that MS example and it works fine for MS type apps, but not for anyhing else. (e.g mp3, oggs)
Is there a more general way to access these 'extra' properties via C++ ?
Thanks
Bats
:}
|
|
|
|