|
You're still not being very precise about what you want to accomplish.
m_ptr = new int( m_nVals ); You do know that this creates an int and initializes it to m_nVals , right?
If you still haven't read the suggestion on std::vector , then I suggest you do that and its documentation.
If you want each item initialized differently, then you should have said so - std::vector can only initialize all items to the same value.
--
The Blog: Bits and Pieces
|
|
|
|
|
It was a mistake.
I meant that
m_ptr = new int [ m_nVals ]
I'm not familar with std::vector.
Can you suggest any further references on std::vector?
Thank you.
- NS -
|
|
|
|
|
Are you asking about this scenario?
class myClass
{
public:
myClass();
};
void main()
{
myClass *objArr=new myClass[20];
}
If so, in this case class's default constructor get called. You need to write one to get this compiled.
And that is your chance for any initialization. This is by design
|
|
|
|
|
|
does anybody know any free tools for format source code?
I know the .NET IDE menu include "Format selection" sub menu,
but, it's not good at format the whole document.
so, do you know the other free tool for format code?
thank you very much.
|
|
|
|
|
Hi,
A bit late in the day, but you could check out http://www.sourceforge.net/projects/astyle. It is a free ware syntax styling and indenting programme for C/C++/java/C#.
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
Ok here i am again the CP having hit my head on the wall as much as possible for this 2 days...
It was more that 1 year i didn't do anything in C#...
now after a lot of ice on my head i got it, my CDAWG
(Word here is a byte pointer)
the class is finally working, it takes imput strings, convert them to bytes and fill the tree... it's very unsafe.... i use ** and * with a clas for the heap memory allocation taken from the examples of the msdn very short code and always worked fine, this is why i am posting to c++ also.
What can i do now???
that's what i did, i took the wikipedia dump file with all their articles names, one per line.
it's 25Mb of a text that have an article name per line...
cool i'm loading it into my class.. and it does the insertion quite faster then what i thought.
the test on word are just WOW.. i mean... almost "instant"
but now the stuff is... why does it take 130Mb of Memory? shoudn't the tree be
"Compact"?
What i wanted to know is if any of you may tell me if this result is "normal"
should a 25Mb file made with one word per line take up to 130Mb when loaded into an normal CDAWG???
<- true inside to understand outside ->
<- true inside to understand outside ->
|
|
|
|
|
Why in Child if I don't specifically call base case and member object's copy ctor, their default ctor is called respectively instead?
#include <iostream>
using namespace std;
class Parent
{
int i;
public:
Parent(int ii) : i(ii) {
cout << "Parent(int ii)\n";
}
Parent(const Parent& b) : i(b.i) {
cout << "Parent(const Parent&)\n";
}
Parent() : i(0) { cout << "Parent()\n"; } friend ostream&
operator<<(ostream& os, const Parent& b) {
return os << "Parent: " << b.i << endl;
}
};
class Member
{
int i;
public:
Member(int ii) : i(ii) {
cout << "Member(int ii)\n";
}
Member(){ cout << "Member()\n"; }
Member(const Member& m) : i(m.i) {
cout << "Member(const Member&)\n";
}
friend ostream&
operator<<(ostream& os, const Member& m) {return os << "Member: " << m.i << endl;
}
};
class Child : public Parent
{
int i;
Member m;
public:
Child(int ii) : Parent(ii), i(ii), m(ii) {
cout << "Child(int ii)\n";
}
Child(const Child& c) : i(c.i) {}
friend ostream&
operator<<(ostream& os, const Child& c){
return os << (Parent&)c << c.m
<< "Child: " << c.i << endl;
}
};
int main() {
Child c(2);
cout << "calling copy-constructor: " << endl;
Child c2 = c;
cout << "values in c2:\n" << c2;
getchar();
}
|
|
|
|
|
Since you've chosen to implement a copy assignment ctor, you really have to do it properly. It's a ctor and it's up to you to choose how to initialize bases and members, just as with the default ctor. When you implement a copy assignment ctor, it's your responsibility to initialize everything correctly. If you don't provide specific initialization for bases or members, their default ctors are used for initialization.
If you don't implement a copy assignment ctor, the compiler will generate one that makes binary copies of PODs and calls copy assignment ctors where such are available.
--
The Blog: Bits and Pieces
-- modified at 2:29 Thursday 20th October, 2005
|
|
|
|
|
Johann Gerell wrote: If you don't provide specific initialization for bases or members, their default ctors are used for initialization.
This sentence is helpful for me to understand, thanks!
Johann Gerell wrote: PODs
|
|
|
|
|
Hi
I currently use an implementation of the GoF observer pattern in C++. i.e. my observing class connects to a subject and then receives updates when it changes state. Having now waded into the Managed C++ arena I find the need to propagate the update call up into Managed C++ world from Unmanaged. My observers inherit from a class much like this:
class Observer
{
public:
virtual void Update(void) = 0;
}
I would love to be able to do the following:
__gc class MyObserver : public Observer
{
...
}
problem solved, but no, __gc classes cannot inherit from __nogc classes. I would like to find an approach which mimicks my existing technique as closely as possible.
Thanks
|
|
|
|
|
You might read this information from MSDN:
Interoperation with Unmanaged Code[^]
Also, here's more:
Interoperability in Managed Extensions for C++[^]
Interop is a complex subject. It kind of depends on what exactly you want to Interop with. Is this a compiled DLL? A COM type library? Or, just a bunch of text source code? Most importantly are the data types compatible?
If it was me, I'd just rewrite everything in .NET framework.
|
|
|
|
|
I'd like to write a command line program that expands command-line arguments just like typical DOS commands, like dir/ren/copy etc.
For example, if I typed "myprog *.doc" my program would get as its arguments the filenames of all doc files in the current directory.
I suppose I could write my own code to do this, but it seemed pretty standard and I was surprised to not find other code that does this.
-Ben
|
|
|
|
|
I think there's an API which takes that string and returns all the files to match.
If not, there's always this[^].
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I know there is an Internet&Networking category, but most of the articles there are for Windows.
Can someone guide me, or tell me a book, on Internet(Server/Client architecture) programming which is independent of the OS is running on?
Thanx!
|
|
|
|
|
sir,
i am confused about virtual functions, what is neccessity of virtual function.in which conditions we make fuctions as virtual .plz tell me about virtual functions
|
|
|
|
|
This question has already been answered here[^]
|
|
|
|
|
sorry I am not good know english.
Hey All friends please Help me.
how write voice Server and client. and client is not one. I am used several client. if All client online I am Look in server.
knowledge -> friends -> Good Team
|
|
|
|
|
read some books
go to school
|
|
|
|
|
horIter[i]->ver !=NULL;
i get this syntax error
250 H:\Dev_Cpp\project\Comp125\ass3\SparseMatrix.cpp base operand of `->' has non-pointer type ` listNode'
what i do to inlcude i via the for loop
|
|
|
|
|
We have absolutely no idea what horIter is, neither which for loop you are talking about !
Now, look at the error message and it should tell you the answer. I suppose you have to change the line to
horIter[i].ver != NULL;
|
|
|
|
|
You should dereference an iterator and use it from there, you should not assume that an iterator is a pointer. VC6 will let you do this, VC7 ( correctly ) will not.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Can someone please help me resolve this question because it is driving me mad. i have been working on it for days and still have nothing.
The question is:
To find value of the sum S for which formula composed. Summation (The act or process of adding) to continue until next composed |a[i]|> E.Ispolzovat a heading file and indexes on function for calculation composed under the formula and indexes on a variable.
I know i have to create a formul but i can't see how if some can help please do beacuse i been working on this for 2 weeks, so please please help.
please help
Jannet
|
|
|
|
|
Your question is hard to understand. Please try to explain it a little better.
|
|
|
|
|
Ask your tutor. That way, he/she will know where you are stuck, and perhaps be able to tailor the lessons so that you can follow them.
Christian Graus - Microsoft MVP - C++
|
|
|
|