|
Try including radio.h and radio.cpp before main.cpp - this error usually occurs when the linker cannot resolve the definitions for the Radio class.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - Writing Word addins
Office addin
|
|
|
|
|
Maybe I am not getting this right because I am new to this, but what do you mean? I have main.cpp which looks like this:
#include <iostream.h>
#include <afxwin.h>
#include "Radio.h"
int main()
{
Radio x; //x is the object called. It is of class type Radio
int Number = 7;
x.Display(Number);
return 0;
}
Radio.cpp is the definitions of Radio.h. Main.cpp is the main program....I dont understand what you mean??
|
|
|
|
|
#include "Radio.cpp" or add the cpp file to the project and rebuild.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - Writing Word addins
Office addin
|
|
|
|
|
Ok, that works! But I have another quick question. I have not had to do this before when compiling C++ projects and I also do not have to do it when I create the project from scratch (I only got this problem when I continued working on a project after I turned my PC off). In both my C++ book and my MFC book they only include the hearder.h file. How come in the books they do not include the header.cpp file? Is this something I am going to have to do with all MFC and C++ projects in the future?
Thank you for your help Kula, this has really been helpful!
|
|
|
|
|
#include "radio.h" into radio.cpp and then #include "radio.h" into main.cpp
That should work!
|
|
|
|
|
I have that and it didnt work
|
|
|
|
|
I'm not sure what compiler you're using, however I use Visual C++ 6.0. When I create a new Win32/Console application and define a new class I simply insert the header file for the class into main.cpp and everything compiles and links just fine. From what I gather of your original post, it sounds like a compiler configuration issue. You might want to consult Microsoft's Knowledge Base just to find out if this is a known issue and if so, how to fix the problem.
I hope this helps.
|
|
|
|
|
I had to readd the files to my workspace for some odd reason. Thanks for all of your help!
|
|
|
|
|
Can anyone point me in the right direction? I have been building a audio app for a couple of months based on DirectMusic, and I have had problems looping .wavs. I'm loading them into a segment, (after the usual initialisation) setting the length, and specifying looping points, but on play back the segments play the entire file and loop from start to finish.
I suspect I am missing out a setup step, but the documentation is pants, and I can't seem to find any tutorials that deal with this. Any help would be greatly appreciated.
|
|
|
|
|
Theres a container class MyClass<t> which has in it a class MyB (declarted in the h file). I am implementing the constructor of MyB. So in the cpp file does it look like:
MyClass<t>::MyB::MyB()
{
}
?
thanks,
ns
|
|
|
|
|
nss wrote:
MyClass::MyB::MyB()
{
}
That looks correct to me.
Happy Programming!
WWW::CodeProject::BNEACETP
|
|
|
|
|
Appreciate the response.Good to get the go-ahead....
ns
|
|
|
|
|
You're welcome!
Happy Programming!
WWW::CodeProject::BNEACETP
|
|
|
|
|
Hi
I’ve got an ATL control (ActiveX) which currently exposes a property page that is used to manipulate all the properties in the control (This property page is launched in the usual manner by the user activating the ‘Custom Properties’ item in the container).
However, instead of displaying a property page to manipulate my control, I need to execute an arbitrary piece of code that displays a custom built editor dialog. My problem is that I cannot find out how to execute an arbitrary piece of code in response to the user clicking the “(custom)”
button on the control container’s property pane (or a similarly easy method of the user activating the editor).
One approach that I have considered is to create and show the dialog from the property page’s InitDialog handler, then destroy the property sheet after the custom dialog has exited (The problem here is knowing how to close the entire property sheet and not just the page) - I'm sure there must be other approaches to this problem though.
Thanks
|
|
|
|
|
Hi,
I try to overload the = operator on a class like following,
CString nomZone;
CArray<ccomposantzone, ccomposantzone=""> composantsZone;
CZone &operator= (const CZone &zone)
{return CZone(zone.nomZone, &(zone.composantsZone));}
but when I build I get this message :
error C2665: 'CZone::CZone' : none of the 4 overloads can convert parameter 2 from type 'const class CArray<class ccomposantzone,class="" ccomposantzone=""> *'
Any idea could help,
thanks,
Pierre
|
|
|
|
|
Do you have a constructor defined for your CZone class that looks similar to this?:
class CZone
{
CZone( CString strNomZone, CArray* pComposantsZoneArray );
};
Another way to implement operator=() is
const CZone& operator=(const CZone& cZone )
{
nomZone = cZone.nomZone;
composantsZone = cZone.composantsZone;
return *this;
}
____________________________________________
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)
|
|
|
|
|
Your operator= method is flawed in many ways. The most notable flaw is that you are returning a dangling reference. You return a reference to a temporary object - an object which is dead after the operator= has returned.
Second, a operator= should return *this so that you do not break the syntax and semantics of obj1 = obj2 = obj3 /* and so on */ ;
As for your error message: Obviously you do not have a CZone(CString, const CArray*) or CZone(const CString&, const CArray*) constructor. Your parameter, zone is const. Hence zone.nomZone and zone.composantsZone are const too.
--
C'est normal!
|
|
|
|
|
Is there anyway (meaning, any tricks of the trade) by which one can set the size of an array at run time?
I am dealing with a 2-dimensional array, and it just seems a waste to set its size at the maximum, only to know that several times during the running of the program, less than 1/10 its size will be used. (Translated another way: From about a megabyte maximum, to a few dozen bytes minimum.)
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
No (unless you can settle with a reallocation of the array). Use a std::vector if you need dynamicity in your "arrays".
--
C'est normal!
|
|
|
|
|
Thanks for replying.
Vector seemed to be the only alternative I know about, but thought someone might know of a clever way to get around the compiler's insistence for a constant integral expression.
William
Fortes in fide et opere!
|
|
|
|
|
std::vector also does a lot of reallocations when it grows, it is just hidden from you. Although you can reduce the number of reallocations needed by using the vector::reserve() function.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
I'm far from an expert but I do have an idea. When you figure out how much of the array is used for that preticular part of your progam, put those numbers into Variables. From there put the variable names into the line where you specify the size of the array. I have a feeling I have no idea what I'm talking about but it seemed like a good idea. I hope it helps you.
|
|
|
|
|
That only works for stack based arrays. And arrays on the stack is a bad coding practice (except for really small, fixed size arrays). Stack space is precious while heap space is not (not as precious as stack space anyway)
--
C'est normal!
|
|
|
|
|
Thanks for replying.
It's a good thought, but if you're serious about maximizing reuse of your code, you cannot have duplicate codes doing the same thing at different locations in your program just so you can take advantage of what you're suggesting.
William
Fortes in fide et opere!
|
|
|
|
|
If you're thinking of something like this:
size_t x, y;
int bigarray[x][y]; then no, that is illegal because array sizes must be known at compile time. (gcc allows this, but it's a non-standard extension.)
You can build your own array at runtime with lots of new calls though.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0.1! | RightClick-Encrypt
"Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."
-- Paul Watson, Linux Zombie
|
|
|
|