|
Hi,
Can I initialize a member array of a class from the constructor
class test<br />
{<br />
<br />
int Myarray[10];<br />
test()<br />
{<br />
<br />
}<br />
};
here I want to set the value of all elements in Myarray as 0. Is there any way to do it with out using memset()...?
nave
|
|
|
|
|
dear why do You not use loop to initialize array with ur desired value.
ajmalsiddiqui
-- modified at 6:50 Monday 8th May, 2006
|
|
|
|
|
in normal case
int MyArray[10] = {0};
will initialize all the elements in that array..I just want to know is this possible in the class memebers( using initialization list )
nave
|
|
|
|
|
Naveen R wrote: using initialization list
Initialization list can only be specified when an array is being declared.
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
I didn't understand? can u plz explain?
nave
|
|
|
|
|
Initializer lists are used in a constructor to initialize members of that class.
Not local variables defined inside a class.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
|
No, I don't think you can ust initializer lists with plain old C-Arrays.
You are bound to use a loop or memset.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
hi all,
I have a dll file named wpdes32.dll for DES encryption/decryption. I need to call this in Vc++ , i couldn't create .def file for this and only know the declaration of functions. How can i call this in vc++??
thanks and regards
jijo
jijo jose
|
|
|
|
|
You can use LoadLibrary[^] to load the dll and then use GetProcAddress[^] to get a specific function (you need to know its name and prototype)
|
|
|
|
|
If that DLL is ATL COM then
with the help of #import directive you can get its methods by creating the instance of the DLL.
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
hi
I would like to get the list of all available domains on a computer in VC++(either MFC or Win32).
which API do i need to use??
thanx in advance
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
-- modified at 6:50 Monday 8th May, 2006
|
|
|
|
|
For finding the domains you have to use :
NETRESOURCE structure and API's such as:
WNetOpenEnum()
WNetEnumResource()
Cheers
"Peace of mind through Technology"
|
|
|
|
|
<br />
class MyClass{<br />
int N;<br />
int M;<br />
MyClass(){<br />
N=0;
M=0;<br />
}<br />
MyClass(int n){<br />
N=n;
}<br />
...<br />
}<br />
<br />
....<br />
<br />
<br />
MyClass X, Y(3);<br />
In debug mode I saw that in both cases (X and Y(3)) the object is created throw the default constructur (N=0), and after that (only in the Y case) there is a call of the other constructor(N=3).
Is this a standard behaviour of C?
So can I put the default initializations ONLY in the first constructor and be SURE that using other constructor I have always an INITIALIZED object(see the variable M)?
Thanks for your time.
|
|
|
|
|
_Russell_ wrote: In debug mode I saw that in both cases (X and Y(3)) the object is created throw the default constructur (N=0), and after that (only in the Y case) there is a call of the other constructor(N=3).
How did you check that ? For the case of Y(3) the default constructor is not called (only the ctor with a parameter is called). I think you did something wrong while debugging.
|
|
|
|
|
mmm....,
yes: there is something strange!
something doesn't work somewhere in the 'real' code class!
sorry to disturb you!
I have to solve by myself this problem
|
|
|
|
|
Hi boy,
Try my code below, and you will see.
--------------------
#include <iostream>
class MyClass
{
int iA;
int iB;
public:
MyClass() : iB(0) {
std::cout << "MyClass() \n";
}
MyClass(int n) : iB(0) {
std::cout << "MyClass(" << n << ") \n";
iA = n;
}
};
int main()
{
std::cout << "MyClass aa; \n";
MyClass aa;
std::cout << "MyClass bb; \n";
MyClass bb(3);
return 0;
}
Maxwell Chen
|
|
|
|
|
Thanks friend.
The error was in another point of my code. Now I got it.
sorry to disturb you.
|
|
|
|
|
hi all
I started to study assembler.
Can I compile assembler code in VS2003.Net ?
If yes where ?
thank you
|
|
|
|
|
You can only compile inline assembler, which means some assembly code in C/C++ source files. As example below:
void foobar()
{
__asm
{
mov AX, 3h
mov BX, 82h
int 17h
}
}
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: You can only compile inline assembler
From your answer, I assume that it would surprise you to learn that this is not true, in the sense that Visual Studio 2003 Pro comes complete with Microsoft's stand-alone assembler (ML, which to me is just a new name for MASM). You can add .ASM files to your project and have them assembled as part of the project, but you need to set up a Custom Build step to do it. At least, that's how I'm doing it in a VS 2003 C++ project I'm working on right now.
|
|
|
|
|
Using C++ you can use inline assembley. i.e.
__declspec(naked) int __stdcall ReturnOne()
{
__asm
{
mov eax, 1
ret
}
}</code>
Steve
|
|
|
|
|
Stephen Hewitt wrote:
__declspec(naked) int __stdcall ReturnOne()<br />
{<br />
__asm <br />
{ <br />
mov eax, 1<br />
ret <br />
}<br />
}
Is this valid based on your code... ?
void foo()<br />
{<br />
__asm CALL ReturnOne
}
Maxwell Chen
|
|
|
|
|
|
why does that "e" comes when its a 32 bit thing?
do we separately have a reg in that name, or its just a part of AX ? like (AL,AH) ??
NULL
|
|
|
|