|
Which compiler are you using? The following compiles fine in VC++ 6.0sp5:
#include <vector>
class myClass{};
typedef std::vector<myClass> MyClassVector;
MyClassVector mcv (100);
int main()
{
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I keep getting a syntax error "C2059: syntax error : 'constant'"
When I try and specify a capacity for a vector based type.
<br />
...<br />
typedef std::vector<myClass> MyClassVector;<br />
...<br />
MyClassVector mcv (100);
<br />
I just stare and stare yet I cannot see the syntax error?
Thanks!
|
|
|
|
|
This is from MSDN Library:
If the error message occurs on a symbol immediately following a typedef'd variable, ensure that the variable has been defined somewhere in the source code.
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
That does seem to apply to my situation as if I don't specify
a capacity i get no syntax error.
<br />
...<br />
typedef std::vector<myClass> myClassVector;<br />
...<br />
myClassVector mcv;
|
|
|
|
|
have you tried
mcv.reserve(100);
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
I have a DLL class that I am exporting,
// Observer Class
class APA_API CStateObserver
{
...
}
class APA_API CStateMachine
{
public:
void PushObserver(CStateObserver * inpObserver);
private:
std::deque<cstateobserver*> m_dqObservers;
}
APA_API is the define that resolves to the correct __dellspec(lalalalalal) etc...
I get this compiler warning message,
warning C4251: 'm_dqObservers' : class 'std::deque<class cstateobserver="" *,class="" std::allocator<class="" *=""> >' needs to have dll-interface to be used by clients of class 'CStateMac
I have 'Warnings as Errors' set so this warning is a real problem.
What are my options?
Cheers
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Did you include the header for the deque container?
Kuphryn
|
|
|
|
|
disable it - I think this is one of the ones you can safely ignore (like warning 4786 about long names)
Also make sure you don't expose it directly, such as
class Foo {
public:
map<int,int> & getTheIntMap() {
return m_map;
}
private:
map<int,int> m_map;
}
exposing it like so will cause you all sorts of problems - just don't go there.
Wrap all access to the collection with functions for adding and removing, which it appears you are doing anyways.
Also you might consider using STLPort - which may give you fewer headaches
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Would you tell me what API support to recognize CD-ROM status when i push the button eject on CD-ROM. Example it can recognize there are CD in CD-ROM or not.
|
|
|
|
|
Specifically I get "LINK : fatal error LNK1561: entry point must be defined"
I searched MSDN and with Google but no luck. Did this happen to anyone else? How did you get it to build?
Cathy
Life's uncertain, have dessert first!
|
|
|
|
|
Generally speaking, a DLL wants a function called DllMain as its default entry point. Do some MSDN searches on DllMain and you should see lots of stuff. There is a sample called DllHusk that is somewhat illustrative.
The Ten Commandments For C Programmers
|
|
|
|
|
Thanks! It turns out it was a typo in the include directory listing. I had accidentally deleted the period in front of \
Cathy
Life's uncertain, have dessert first!
|
|
|
|
|
check for _USRDLL being defined. See if subsystem is windows. Do you have any weird linker customizations? Just a thought (I actually don't have VC7 so I may be completely off base )
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Thanks! It turns out it was a typo in the include directory listing. I had accidentally deleted the period in front of \
So yes I guess I had a pretty weird linker customization goin on.
Cathy
Life's uncertain, have dessert first!
|
|
|
|
|
Hi. I want to call one method, which i have declared in a Dialog´s Class from other class. So, in the second class i have a varible CDialog* pWnd; which is initialized by SetParent(CDialog *p) . Then, in the dialog I call secondclass.SetParent(this) . then i add the #include "mydlg.h" in seconclass.cpp
All that work fine. However, when i try to use any dialogclass's method in secondclass as ((CmyDlg*)pWnd)->NuevaTarea(strRecvd); doesn´t work
But when i compile this message appear : error C2065: 'IDD_SPOOLERSUR_DIALOG' : undeclared identifier
error C2057: expected constant expression
(SpoolerSur is my Cdialog class)
el hombre arriesga su vida cada vez que elige y eso es lo que lo hace libre
|
|
|
|
|
Martin_Viet wrote:
then i add the #include "mydlg.h" in seconclass.cpp
But when i compile this message appear : error C2065: 'IDD_SPOOLERSUR_DIALOG' : undeclared identifier
error C2057: expected constant expression
You also need to include the "resource.h" file in secondclass.cpp
Max..
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Max : i included the Resource.h but it appear the same error
el hombre arriesga su vida cada vez que elige y eso es lo que lo hace libre
|
|
|
|
|
|
i´d solved the problem. i need to include the Application header file("MyAppl.h")
el hombre arriesga su vida cada vez que elige y eso es lo que lo hace libre
|
|
|
|
|
How to send message from VC7 to IE6 ??? (eg. select internet page)
|
|
|
|
|
One solution is FindWindow() and SendMessage().
Kuphryn
|
|
|
|
|
To open a page you can use ShellExecute()
el hombre arriesga su vida cada vez que elige y eso es lo que lo hace libre
|
|
|
|
|
Hi,
Is there a way to execute a MFC app with an arguments? I would like to do something like:
Get a Filename and Filepath from a database. Launch the app with that file loaded.
Thanks for helping.
Regards
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Check CCommandLineInfo or, if you want to do the things as in console programs, use __argc and __argv .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
also you can customize CCommandLineInfo with your own derived class and then pull arguments out as you need them.
You can do some nifty things this way.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|