One solution can help you to make something new: class Array2D { public: Array2D(int w, int h):width(w), height(h), array(w*h) {} ... ... protected: int width, height; Array array; } template class Array3D :public Array2D { public: Array3D(int l, int w, int h) : Array2D( w, h), length(l) {} ... ... protected: int length; //Array< Array2D > array; }
Branislav
Posts
-
Questions about creating a 3D array class -
problem exporting static template data members, but not methods"Windows requires all public symbols to be explicitly exported from a DLL via the __declspec(dllexport) syntax (and correspondingly dllimported when referenced in some other DLL). I guess it works pretty well on C libraries. But it doesn't work so well on C++ libraries, particularly with template classes--the template itself, of course, doesn't have a link-time presence, so it doesn't make sense to dllexport a template. What you really mean to export is the template instantatiation. But template instantiations are implicit, according to the language, so where do you put the dllexport syntax? Microsoft came up with a place to put the dllexport syntax, which is to explicitly put a line like this in the DLL that exports a particular template instance: Code: template class __declspec(dllexport) my_template_class; And also put a line like this in a DLL that imports that template instance: Code: extern template class __declspec(dllimport) my_template_class; These lines must be the first instantiation of the template instance, which means they must be seen by the compiler before any other reference to my_template_class. Of course, this is a Microsoft extension to C++ syntax; the language itself does not require this sort of declaration (and non-Microsoft compilers won't understand it). The problem with this declaration is that it explicitly expands and exports all methods and components of the template class, whether they are actually used or not; and it requires that nested template classes be explicitly exported before their containing classes are exported. That's not too bad, but it turns out that the standard STL implementation of list, map, set, multiset, multimap--basically everything other than vector--use nested template classes that are mutually recursive. That is, the nested class includes references to the containing class, and vice-versa. This makes it impossible to export the nested classes first, since expanding them requires expanding the containing class--which has not been exported yet, violating the rule that the export syntax must appear before the first instance is encountered. Similarly, you can't export the containing class first, which would expand the nested class before its export syntax. This means that none of the STL classes except for vector can be exported from a DLL. But do you really need to export a template instance from a DLL? Isn't each instance of a template technically a completely new copy of the class? If you don't even try to e
-
external programThe linker is looking for the entry point for a console application, but the application is being compiled and linked as a windows application (i.e. not a console application). This error has been observed after changing the project settings from using MBCS to UNICODE characters. Under the project settings, under the ‘Link’ tab, category ‘output’, set the ‘Entry-point symbol’ to ‘wWinMainCRTStartup’.
-
problem exporting static template data members, but not methodsA data member of a class can be declared static; be it in the public or private part of the class definition. Such a data member is created and initialized only once, in contrast to non-static data members, which are created again and again, for each separate object of the class. A static data member is created once: when the program starts executing. Nonetheless, it is still part of the class. Static data members which are declared public are like `normal' global variables: they can be reached by all code of the program using their name, together with their class name and the scope resolution operator. This is illustrated in the following code fragment: #include template class C { public: static int n; }; The data member n is a private static variable. During the execution of the program, only one C::n exists, even though more than one object of the class C may exist. This data member could be inspected or altered by the constructor, destructor or by any other member function of the class C.
-
CHotKeyCtrl and "space"Try with: UnregisterHotKey(...) m_hotkey1.GetHotKey(...) ... RegisterHotKey(...) m_hotkey1.SetHotKey(...) RegisterHotKey modifier flags defined in "CommCtrl.h" and "WinUser.h" are not same. The values for fsModifiers are defined in "WinUser.h".
-
Parallel port and MFC application integrationYou can use inpout32.dll. Look on: http://logix4u.net/[^]
-
DATETIMEPICKER Flat -
Another Drag and Drop Question -
How to Print the Text in Required Format. -
How to simulate DoEvents() in Visual C++? -
Rounding problemTry with this: char sInteresse[30], sTotale[30]; sprintf(sInteresse, "%14.14f", Interesse); sprintf(sTotale, "%14.14f", Totale);
-
How to delete values and header from ListCtrlint nColumnCount = m_ListCtrl.GetHeaderCtrl()->GetItemCount(); // Delete all of the columns. m_ListCtrl.DeleteAllItems(); for (int i=0;i < nColumnCount;i++) { m_ListCtrl.DeleteColumn(0); // always delete first column } You delete all items with m_ListCtrl.DeleteAllItems() and only first column.
-
button catch double click.Try to use BN_DOUBLECLICKED and your button need to be Notify.
-
BN_DOUBLECLICKEDDid you select Notify in Puch Button Properties - Styles dialog box?
-
Serial Port communicationI think that you have null modem connection. DTR -> DSR are continual signal. When you set DTR signal on high that means you are redy to send data but when your DSR become high that mean you can receive data from device. When you start to configure port set DTR signal with DTR_CONTROL_DISABLE and fDsrSensitivity in DCB with TRUE to avoid flow, but watch all changing are valid after calling function SetCommState. Now you can control DTR with function EscapeCommFunction and monitoring DSR. My recommmendation is whenever use EscapeCommFunction(hFile, CLRDTR | CLRRTS ) or EscapeCommFunction(hFile, SETDTR | SETRTS).
-
Access 2000 Ole IntegrationMaybe this article can help you: http://support.microsoft.com/?kbid=266387[^]
-
BN_DOUBLECLICKED -
Serial Port communication -
Sir,can you help meBefore use any function to call driver you must start driver service if you did not have automatic start during instalation driver. For more details see http://www.l5sg.com/products/source_code.php source code for tipical install, start and stop a service or driver. You can use that code to open and start driver before call CreateFile, ... and after, before the end of your program, close service or driver. All you can check in Administrative Tools\Services. And most important thing is that you must be Administrator or privelege level like administrator.
-
Accessing Error-Checking of local hard drives in XP (in c++ code)