|
I am afraid you can not do like this
NNN nnn[]={<br />
{10}, {20},<br />
};
Why you are passing 10 and 20 when you are doing nothing with them.
secondly, you are making an array of a class. To initialize it, you can not give it an integer value.
You want to initialize ia in the constructor, then why to pass 10 and 20. memset will initialize the array.
Good luck.
We Believe in Excellence
www.aqueelmirza.cjb.net
-- modified at 0:00 Friday 28th April, 2006
|
|
|
|
|
ask for why?
u r speaking to yourself.
|
|
|
|
|
Oh! includeh10!
It is a way of telling other person and pointing out where could be the problem. I use it commonly and it works perfectly fine. I apologize! If you dislike it.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
includeh10 wrote: how to solve the problem to let the class contain constructor to initialize data?
I didn't understand what u really needed. Anyway u can solve it by just changing the constructor like this
NNN(int)
{
memset(&ia,100,sizeof(ia));
}
- NS -
|
|
|
|
|
NS17 wrote: didn't understand what u really needed
so delete your reply to make the post clear.
|
|
|
|
|
are you on drugs ?
|
|
|
|
|
|
Michael Dunn wrote: NNN foo[] = { NNN(), NNN() };
What is the need of that? NNN foo[2] is enough, isn't it?
- NS -
|
|
|
|
|
NS17 wrote: NNN foo[2] is enough, isn't it?
Yes, if the default ctor is sufficient. The OP asked about initializing the objects in an array at the time that the array is created.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
The code below compiles and works fine.
[Edited] When you use memcpy in your original version, you will see
nnn[0].ia[0] = 0x0a0a0a0a;
nnn[0].ia[1] = 0x0a0a0a0a;
nnn[1].ia[0] = 0x14141414;
[/Edited]
class NNN
{
enum { size = 100 };
int ia[size];
public:
NNN(int n) {
for(int i = 0; i < size; i++) {
ia[i] = n;
}
}
};
int main()
{
NNN nnn[]={ 10, 20, 30 };
return 0;
}
Maxwell Chen
-- modified at 2:17 Friday 28th April, 2006
|
|
|
|
|
Hello all
I have several binaries say ProductA1.exe ,ProductA2.exe and ProductA3.exe . My question is about a piece of code in all these binaries.(Though the binaries A2 and A3 differ in some other .cpp files , the code I am pasting below is exactly the same in all of them ..)
Purpose of the code : This code launches a .chm help file .
Code :
FunctionOne()
{
.....
.....
if(dwData != 0)
{
if(HtmlHelp(hwndCaller,
lpszHelpFile,
HH_HELP_CONTEXT,
dwData) == NULL)
{
HtmlHelp(hwndCaller,
lpszHelpFile,
HH_HELP_CONTEXT,
(DWORD)HELPID_ABOUT);
}
}
else
{
HtmlHelp(hwndCaller,
lpszHelpFile,
HH_DISPLAY_TOC,
(DWORD)HELPID_ABOUT);
}
.....
}
Problem : When I launch ProductA1.exe , the .chm file is not launched as the code enters the block if(dwData!=0) . But when I launch ProcuctA2.exe the help file is started . But in ProductA3.exe it again does not work !!!!
So I set active config as "Debug" and debugged the relevantfile.cpp and found that it works fine . But surprisingly only once I was able to reproduce the problem . ie => The same lines of code were executed and HtmlHelp( ) function was called but there was no help file shown on screen !!! . The behaviour same like ProductA1 and ProductA3 release EXEs.
So I set active config as "Release" and debugged (with "generate debug info" on in settings) again the beahvior is good !!
I put a dialog box inside the if blocks and replaced the my release exe with ProductA1 and ProductA3.exe , it works fine .
My question : Is it code optimization problem ? I can disable optimization using #pragma optimize ("", off) . But I strongly feel it is not code optmization problem becasue , i have seen variable values becoming junk in release and not in debug .
But in my case the sames EXEs are differing in behavioir .And also the behavior is confusing . And surprisingly when i started help from my collegues systems the help starts in all EXEs !! All the systems have XP SP2 1 GB RAM.
Can anyone throw any ideas ?
redindian
-- modified at 22:29 Thursday 27th April, 2006
|
|
|
|
|
problem is with your code only, seems it works in debug and not in release!!! watch your code closely for any chance in loosely handled memory. or just share your code, it is a debugging challenge...!!!!
Loka Samastha Sukhino Bhavanthu..!!!
( May all beings be happy and free )
|
|
|
|
|
I set the style of my list
m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_HEADERDRAGDROP);
But everytime after I drag and drop a header, for example drag column 1 to column 2. The data area moved as well and it starts from column 2, column 1 area becomes empty, all data moved to column 2 & 3, some of them mixed together. Is there any other style I should set or any additional code I should wrote?
Thanks!
|
|
|
|
|
R u owner drawing the list control?
nave
|
|
|
|
|
For example, using the example project WTL for MFC part 1 (http://www.codeproject.com/wtl/wtl4mfc1.asp[^])
Smallest Release EXE I could get for VC++ 2005 was about 55KB compared to 28KB for VC++ 2003 and 34.5KB for VC++ 6.0.
What's the reason for it ?
|
|
|
|
|
My guess is extra security features build into the CRT library. That requires more code, so you get larger binaries.
If VC8 still supports the linker switch /opt:nowin98 don't forget to add that, as it will usually reduce the binary's size a bit.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Is there any way to remove these extra security features since it does seem to add a hefty chunk extra onto each compiled app ?
Or would it be OK to use the CRT library from VC++ 2003 ?
If so, which file(s) should I replace ?
|
|
|
|
|
Hi,
I tried to search for this in MSDN, but was unsuccessful after 30 minutes of trying....
Does anyone know how to access a file's Properties - like when you Right Click a .TXT file, and then click the Summary tab....
I want to programmatically put my own info in the Summary fields for:
1) Title
2) Author
3) Comments
... and do it all from my VC++ (MFC) code.
Thanks,
Johnny
|
|
|
|
|
|
john john mackey
I saw your answer in codeproject but i'm sorry i dont know address
|
|
|
|
|
That's "compound document" information. See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Thanks! I want to stuff info into these fields that I would otherwise have to extract in the "data" files I create. With these props set, I can just "mouse-over" a file listing in (File) Explorer and get a quick summary.
Johnny
|
|
|
|
|
I saw such c codes:
struct A {
...
}
int fun(long x)
{
...
A z=(struct A *)&fun;
...
}
How to explain that? can anybody help?
Thanks!
|
|
|
|
|
Declare a variable z of type A which takes the value of the address of the function fun .
The tigress is here
-- modified at 18:36 Thursday 27th April, 2006
|
|
|
|
|
It could be code which accesses the machine code of the function fun at runtime. What was the contents of the structure?
Steve
|
|
|
|