Click here to Skip to main content
15,897,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: convert mjpeg to mpeg4 Pin
«_Superman_»11-May-10 7:42
professional«_Superman_»11-May-10 7:42 
QuestionHow to register a dll on Window 7 machine. Pin
pandit8410-May-10 20:39
pandit8410-May-10 20:39 
AnswerRe: How to register a dll on Window 7 machine. [modified] Pin
_AnsHUMAN_ 10-May-10 21:47
_AnsHUMAN_ 10-May-10 21:47 
QuestionRe: How to register a dll on Window 7 machine. Pin
pandit8411-May-10 0:02
pandit8411-May-10 0:02 
AnswerRe: How to register a dll on Window 7 machine. Pin
Electron Shepherd11-May-10 2:49
Electron Shepherd11-May-10 2:49 
QuestionCreate Visual Studio Project Pin
Game-point10-May-10 19:51
Game-point10-May-10 19:51 
AnswerRe: Create Visual Studio Project Pin
Richard MacCutchan10-May-10 21:21
mveRichard MacCutchan10-May-10 21:21 
Questionproblem with std::map insertion with a std::vector type object Pin
gourishsio10-May-10 19:33
gourishsio10-May-10 19:33 
Hi,
I was trying to compile the following code,
but it give the error that "tmpname cannot appear in constant expression"
I am using the g++ compiler


#include <iostream>
#include <vector>
#include <map>
#include <string>

class TidePhaseAmp
{
public:
	float amp;
	float phase;
};

main ()
{

	std::map< std::string, std::vector<TidePhaseAmp> > extracted_tConst;

	const char * tmpname = "2n2";
	extracted_tConst.insert(std::pair<std::string, std::vector<TidePhaseAmp>>(tmpname, std::vector<TidePhaseAmp>(5)));

	return(0);

}


the compile error messages are
test_map2.cpp: In function ‘int main()’:
test_map2.cpp:19: error: ‘tmpname’ cannot appear in a constant-expression
test_map2.cpp:19: error: a comma operator cannot appear in a constant-expression
test_map2.cpp:19: error: a call to a constructor cannot appear in a constant-expression
test_map2.cpp:19: error: ‘>>’ should be ‘> >’ within a nested template argument list

however the program does not gives any error when I compile it using visual studio 2008 express compiler

is the problem because I am using a constructor in the statement .i.e. std::vector<TidePhaseAmp>(5)
or is there any other workaround for the problem

Gourish
AnswerRe: problem with std::map insertion with a std::vector type object PinPopular
Graham Breach10-May-10 20:23
Graham Breach10-May-10 20:23 
AnswerRe: problem with std::map insertion with a std::vector type object Pin
Stuart Dootson10-May-10 22:15
professionalStuart Dootson10-May-10 22:15 
GeneralRe: problem with std::map insertion with a std::vector type object Pin
gourishsio11-May-10 2:26
gourishsio11-May-10 2:26 
Questionhow to insert checkbox in any coloum in the list view control Pin
yinglai10-May-10 17:08
yinglai10-May-10 17:08 
AnswerRe: how to insert checkbox in any coloum in the list view control Pin
CPallini10-May-10 21:55
mveCPallini10-May-10 21:55 
GeneralRe: how to insert checkbox in any coloum in the list view control Pin
yinglai11-May-10 18:24
yinglai11-May-10 18:24 
Questionruntime error Pin
mrby12310-May-10 10:19
mrby12310-May-10 10:19 
QuestionRe: runtime error Pin
CPallini10-May-10 10:44
mveCPallini10-May-10 10:44 
QuestionRe: runtime error Pin
David Crow12-May-10 3:12
David Crow12-May-10 3:12 
AnswerRe: runtime error Pin
mrby12312-May-10 6:37
mrby12312-May-10 6:37 
Questionhow to write output from a c++ program to a subdirectory of a directory where the .exe resides. Pin
mrby12310-May-10 8:46
mrby12310-May-10 8:46 
AnswerRe: how to write output from a c++ program to a subdirectory of a directory where the .exe resides. Pin
Maximilien10-May-10 8:51
Maximilien10-May-10 8:51 
AnswerRe: how to write output from a c++ program to a subdirectory of a directory where the .exe resides. Pin
David Crow10-May-10 8:57
David Crow10-May-10 8:57 
GeneralRe: how to write output from a c++ program to a subdirectory of a directory where the .exe resides. Pin
mrby12310-May-10 18:41
mrby12310-May-10 18:41 
GeneralRe: how to write output from a c++ program to a subdirectory of a directory where the .exe resides. Pin
David Crow12-May-10 2:40
David Crow12-May-10 2:40 
GeneralRe: how to write output from a c++ program to a subdirectory of a directory where the .exe resides. Pin
mrby12312-May-10 6:35
mrby12312-May-10 6:35 
AnswerRe: how to write output from a c++ program to a subdirectory of a directory where the .exe resides. Pin
David Crow12-May-10 7:26
David Crow12-May-10 7:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.