Serving the Quantitative Finance Community

 
User avatar
neoPhyte
Topic Author
Posts: 2
Joined: October 18th, 2002, 10:30 pm

hey can anyone help me with my c++ prg.

October 18th, 2002, 10:44 pm

Well here is the question. i need to add a method named "removeVal" to the below class templete. It has to remove all entries in the stack that match a given parameter. i have to accomplish this with pop and push methods. now the conditions are that if the entry on the stack does not match the selected remove value then pop that value and add it to a temp list. this must go on until all entries are checked. then the val is to be removed from the temp list(in reverse order of the add) and push back onto the original stack. thanks
Attachments
New Folder.zip
(953 Bytes) Downloaded 106 times
 
User avatar
Simplicio

hey can anyone help me with my c++ prg.

October 21st, 2002, 4:34 pm

Bit confused - there is no template in this file, it is in the header file referred to.I don't see the problem though - why not just create a second stack, pop off one onto the other, unless the value matches in which case just pop and don't push. At the end pop from the temporary one and push back onto the original? Maybe the question would help?
 
User avatar
ExSan
Posts: 493
Joined: April 12th, 2003, 10:40 am

hey can anyone help me with my c++ prg.

September 23rd, 2013, 9:50 pm

Can some one help me with this.I am using MS Express 2012 My project has several .cpp modulesI need to access a file which I need to be declared as global, so any of my module can send their output to itmy code looks like this:_______________________________________________global.h#ifndef GLOBAL_VARIABLES_H#define GLOBAL_VARIABLES_Hunsigned long int master_dim = 900;const char out_file_name[30] = "c:\\out.txt" ;const fstream fout(out_file_name);#endif __________________________________________________main.cpp#include "stdafx.h"#include <iostream>#include <iomanip>#include <fstream>using namespace std;int _tmain(int argc, _TCHAR* argv[]){ cout << "\n global variable -----> " << master_dim; // ok fout << data << "data to global file" << endl; fout.close(); return 0;}-------------------------at the compile time I get this errorError 1 error C2678: binary '<<' : no operator found which takes a left-hand operand of type 'const std::fstream' (or there is no acceptable conversion)thnks in advance
°°° About ExSan bit.ly/3U5bIdq °°°
 
User avatar
mj
Posts: 12
Joined: December 20th, 2001, 12:32 pm

hey can anyone help me with my c++ prg.

September 23rd, 2013, 11:43 pm

try deleting the const before fstream
 
User avatar
tags
Posts: 3162
Joined: February 21st, 2010, 12:58 pm

hey can anyone help me with my c++ prg.

September 24th, 2013, 4:53 am

And don't you need a #include "global.h" directive in your main.cpp file?
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

hey can anyone help me with my c++ prg.

September 24th, 2013, 9:47 am

QuoteOriginally posted by: outrunQuoteOriginally posted by: edouardAnd don't you need a #include "global.h" directive in your main.cpp file?that's indirectly in the stdafx.h, which is Visual studio trick to speed up compilation. I always get rid of that the few times I code on windows. It's good to clean things up and make it simpler. E.g. you can also say (in this case)int main() instead of int _t main(int argc, _TCHAR* argv[])If you create a Console project and then application setting (empty project!). Much cleaner. TCHAR jikes
Last edited by Cuchulainn on September 23rd, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
ExSan
Posts: 493
Joined: April 12th, 2003, 10:40 am

hey can anyone help me with my c++ prg.

September 24th, 2013, 9:54 am

QuoteOriginally posted by: edouardAnd don't you need a #include "global.h" directive in your main.cpp file?I have this on stdfax.h#include "global.h"cout << "\n global variable -----> " << master_dim; // ok cout << "\n file name -----> " << out_file_name;these two lines on main work fine, I get the right output
Last edited by ExSan on September 23rd, 2013, 10:00 pm, edited 1 time in total.
°°° About ExSan bit.ly/3U5bIdq °°°
 
User avatar
ExSan
Posts: 493
Joined: April 12th, 2003, 10:40 am

hey can anyone help me with my c++ prg.

September 24th, 2013, 10:12 am

QuoteOriginally posted by: outrunI always get rid of that the few times I code on windows. It's good to clean things up and make it simpler. E.g. you can also say (in this case)int main()instead of int _t main(int argc, _TCHAR* argv[])GUYS, THANKS FOR YOUR KINDNESS AND HELPStill does not compile-----------------------------------//stdfax.h#pragma once#include "targetver.h"#include <stdio.h>#include <tchar.h>// TODO: reference additional headers your program requires here// standard Library#include <stdlib.h>#include <iostream>#include <iomanip>#include <fstream>#include <conio.h> // Supports _getch()//Other Library#include "global.h"------------------------------------//#include "global.h"#ifndef GLOBA_H#define GLOBAL_Hconst char out_file_name[30] = "c:\\out.txt" ;using namespace std;fstream fout(out_file_name );#endif ------------------------------------// main.cpp#include "stdafx.h"using namespace std;int main(int argc,char **argv) { fout << data << "data to global file"; fout.close(); return 0;}=======================================errors reportError 2 error LNK2005: "class std::basic_fstream<char,struct std::char_traits<char> > fout" (?fout@@3V?$basic_fstream@DU?$char_traits@D@std@@@std@@A) already defined in ExSan.obj D:\Mis Documentos\Visual Studio 2012\Projects\ExSan\ExSan\stdafx.obj ExSanError 3 error LNK1169: one or more multiply defined symbols found D:\Mis Documentos\Visual Studio 2012\Projects\ExSan\Debug\ExSan.exe 1 1 ExSan
Last edited by ExSan on September 23rd, 2013, 10:00 pm, edited 1 time in total.
°°° About ExSan bit.ly/3U5bIdq °°°
 
User avatar
tags
Posts: 3162
Joined: February 21st, 2010, 12:58 pm

hey can anyone help me with my c++ prg.

September 24th, 2013, 10:20 am

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunQuoteOriginally posted by: edouardAnd don't you need a #include "global.h" directive in your main.cpp file?that's indirectly in the stdafx.h, which is Visual studio trick to speed up compilation. I always get rid of that the few times I code on windows. It's good to clean things up and make it simpler. E.g. you can also say (in this case)int main() instead of int _t main(int argc, _TCHAR* argv[])If you create a Console project and then application setting (empty project!). Much cleaner. TCHAR jikesIt's not clear to me what stdfax.h is for (this seems a bit too much MS, even for me)I always create "console projects" as you advise.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

hey can anyone help me with my c++ prg.

September 24th, 2013, 10:23 am

QuoteOriginally posted by: edouardQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunQuoteOriginally posted by: edouardAnd don't you need a #include "global.h" directive in your main.cpp file?that's indirectly in the stdafx.h, which is Visual studio trick to speed up compilation. I always get rid of that the few times I code on windows. It's good to clean things up and make it simpler. E.g. you can also say (in this case)int main() instead of int _t main(int argc, _TCHAR* argv[])If you create a Console project and then application setting (empty project!). Much cleaner. TCHAR jikesIt's not clear to me what stdfax.h is for (this seems a bit too much MS, even for me)I always create "console projects" as you advise. As outrun has told itAchtung<<EMPTY>>console projects
Last edited by Cuchulainn on September 23rd, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
dd3
Posts: 4
Joined: June 8th, 2010, 9:02 am

hey can anyone help me with my c++ prg.

September 29th, 2013, 10:06 pm

You should not create objects in header files. Read up about the 'extern' keyword
 
User avatar
ExSan
Posts: 493
Joined: April 12th, 2003, 10:40 am

hey can anyone help me with my c++ prg.

October 1st, 2013, 11:14 pm

QuoteOriginally posted by: dd3You should not create objects in header files. Read up about the 'extern' keywordI just need to access a file from different modules. as an output file
°°° About ExSan bit.ly/3U5bIdq °°°
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

hey can anyone help me with my c++ prg.

October 2nd, 2013, 9:10 am

Why not just pass it around as an argument?Do you _really_ need to access it from _everywhere_ else?
 
User avatar
ExSan
Posts: 493
Joined: April 12th, 2003, 10:40 am

hey can anyone help me with my c++ prg.

October 2nd, 2013, 10:47 am

QuoteOriginally posted by: PolterWhy not just pass it around as an argument?Do you _really_ need to access it from _everywhere_ else?yes, I do.along my project I have the instructioncout << ... /// for console outputbut also I have fout << ... // whe I want to sent the output to the out_file.txt passing it as an argument wouldn't be a good idea.I need to access it as a gloval variable.My late project was written in Visual C++ 6.0my computer just collapsed and I had to move all my code to the new platform Windows 7 and Visual Studio 2012Unfortunately I can not install my Visual C 6.0++ in the new windows 7 because this OS is 64 bits and does not allow me to install my old Visual C/C++ 6.0 32 bitsI found this, and still can not do muchhttp://superuser.com/questions/459396/how-do-i-run-visual-c-6-ide-on-windows-vista-or-higherhow-do-i-run-visual-c-6-ide-on-windows-7...stuck for a while ....coding on the que: tensors, Efficient algorithm to compute all permutations of set {1,2,....,n} among others
°°° About ExSan bit.ly/3U5bIdq °°°