Views: 20,008,020 |
Home
| Forums
| Uploader
| Wiki
| Object databases
| IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search |
04-23-24 06:50 AM |
Guest: |
0 users reading Error C2084 visual C++ | 1 bot |
Main - Computers and technology - Error C2084 visual C++ | Hide post layouts | New reply |
FinalShroom81 |
| ||
Member Hoogmin Level: 17 Posts: 34/56 EXP: 22626 Next: 2117 Since: 04-29-16 Last post: 2117 days ago Last view: 1347 days ago |
This may or may not be the right place for this but I have a problem that I need to get fixed. So I was writing a program in C++ when I came across an annoying error. The error is C2084. You can click here for more info about the error. I have looked through many stackoverflow posts to find an answer but to no success. But I have some clues. First I know that this error is a runtime error and has nothing to do with syntax. Second, My program has two classes and both include many header files which may be the source of my problem. I have a whole video on this error. click here to watch it. For some reason, I feel like this error is specific to the visual C++ compiler and if I were to try it in another compiler(e.g. GNU GCC or G++) then it would compile and run just fine. I have yet to try it but I will if I don't find a solution soon.
So here is the code were the error is occuring:(Terminal.cpp) #include "stdafx.h"
If you all need anymore info then I will be happy to give it to you. Thank you all in advance, I truly appreciate every response I can get.#include "Terminal.h" #include <iostream> #include <string> #include <conio.h> #include "StringReverse.h" Terminal::Terminal() { } Terminal::~Terminal() { } void Terminal::Setup() { system("title Cooper City High Showcase Program by Javier Martinez 2017"); //.c_str() is for converting the std::string to const char* system(_lightGreen.c_str()); } void Terminal::RenderMainMenu() { std::string input; std::cout << "\tMAIN MENU\t" << "Type number to select option:\n\n"; std::cout << "1. Preferences\n\n"; std::cout << "2. Word Reversal\n\n"; std::cout << "3. Description\n\n"; std::cout << "4. Exit Program\n\n"; std::cout << "________________________\n\n"; std::cin >> input; Terminal::NavigateBasedOnSelection(input); } void Terminal::NavigateBasedOnSelection(std::string in) { if (in == "1") { Terminal::RenderPreferencesMenu(); } else if (in == "2") { Terminal::NotImplementedNotification(); } else if (in == "3") { Terminal::DisplayDescription(); } else if (in == "4") { system("EXIT"); } else { Terminal::ResetBackToMainMenu(); } } void Terminal::ResetBackToMainMenu() { std::cout << "Invalid Selection, Please try again."; _getch(); system("cls"); Terminal::RenderMainMenu(); } void Terminal::RenderPreferencesMenu() { system("cls"); std::string input; std::cout << "\tPREFERENCES MENU\t" << "Change the font color:\n"; std::cout << "1. Gray\n\n"; std::cout << "2. Blue\n\n"; std::cout << "3. Light Green\n\n"; std::cout << "4. Aqua\n\n"; std::cout << "5. Light Aqua\n\n"; std::cout << "6. Light Red\n\n"; std::cout << "7. Light Purple\n\n"; std::cout << "8. Yellow\n\n"; std::cout << "9. Return to Main Menu\n"; std::cout << "____________________________\n\n"; std::cin >> input; Terminal::ColorSwitchBasedOnSelection(input); } void Terminal::ColorSwitchBasedOnSelection(std::string in) { if (in == "1") { system(_gray.c_str()); Terminal::BasicReset(); } else if (in == "2") { system(_blue.c_str()); Terminal::BasicReset(); } else if (in == "3") { system(_lightGreen.c_str()); Terminal::BasicReset(); } else if (in == "4") { system(_aqua.c_str()); Terminal::BasicReset(); } else if (in == "5") { system(_lightAqua.c_str()); Terminal::BasicReset(); } else if (in == "6") { system(_lightRed.c_str()); Terminal::BasicReset(); } else if (in == "7") { system(_lightPurple.c_str()); Terminal::BasicReset(); } else if (in == "8") { system(_yellow.c_str()); Terminal::BasicReset(); } else if (in == "9") { /*Not a color switch but brings the user back to the main menu of the program*/ Terminal::BasicReset(); } else { std::cout << "Invalid Selection, please try again."; _getch(); RenderPreferencesMenu(); } } void Terminal::BasicReset() { system("cls"); Terminal::RenderMainMenu(); } void Terminal::NotImplementedNotification() { system("cls"); std::cout << "This feature has not yet been Implemented."; _getch(); BasicReset(); } void Terminal::DisplayDescription() { system("cls"); std::cout << _description << "\n\n1/6/2017 - 1/14/2017"; _getch(); Terminal::BasicReset(); } void Terminal::RenderWordReversal() { std::string input; std::cout << "\tWORD REVERSAL\t" << "Type in a word and press return:\n\n"; std::cout << "Type anything then press enter:\t"; std::cin >> input; std::string reverInput = StringReverse::ReverseWord(input); std::cout << "\n\nThe word in reverse:\t" << reverInput << "\n\n"; _getch(); Terminal::BasicReset(); } |
Yami |
| ||
(ーωー。) Level: 60 Posts: 782/959 EXP: 1737981 Next: 34797 Since: 12-07-14 From: Japan Last post: 2478 days ago Last view: 2476 days ago |
Funny how you can compile something using G++, while having "#include "stdafx.h"" or "system("cls");" in your code, which are all Visual C++-specific stuff...
But any errors you get would be more helpful to know, than some incomplete code that we could get from the video you linked to as well. Also, never use "system" in C++. http://www.cplusplus.com/forum/articles/11153/ |
Arisotura |
| ||
Star Mario in this room you have a pile of apple pies Level: 163 Posts: 7198/9019 EXP: 56245944 Next: 241700 Since: 07-03-12 From: in a box Last post: 11 days ago Last view: 11 hours ago |
poudink |
| ||
Bob-Omb [sic] Level: 49 Posts: 177/616 EXP: 833814 Next: 50069 Since: 03-01-16 From: Québec (Canada) Last post: 895 days ago Last view: 829 days ago |
He said he used visual C++. ____________________ Nothing to say, so jadnjkfmnjamnfjkldnajfnjkanfjdksan jsdnvj m. |
Yami |
| ||
(ーωー。) Level: 60 Posts: 784/959 EXP: 1737981 Next: 34797 Since: 12-07-14 From: Japan Last post: 2478 days ago Last view: 2476 days ago |
Posted by StapleButter Posted by FinalShroom81 |
Arisotura |
| ||
Star Mario in this room you have a pile of apple pies Level: 163 Posts: 7201/9019 EXP: 56245944 Next: 241700 Since: 07-03-12 From: in a box Last post: 11 days ago Last view: 11 hours ago |
Posted by FinalShroom81 which says he hasn't actually done it. regardless, having the full error message and line it's occuring on, could help us there. having a blob of code and an error number alone isn't very helpful. ____________________ NSMBHD - Kafuka - Jul melonDS the most fruity DS emulator there is zafkflzdasd |
FinalShroom81 |
| ||
Member Hoogmin Level: 17 Posts: 35/56 EXP: 22626 Next: 2117 Since: 04-29-16 Last post: 2117 days ago Last view: 1347 days ago |
Does anyone know of any sites I can post my full code on? I want to do this so that you can get the full context and help me figure out the source of this error. Also, I have not tried anything with GNU GCC or G++ yet. I said that I feel like it would work. As for using "system()" in c++ I have my reasoning for using it. First, I don't know of any other way to execute windows commands right now. Second, This is a windows console application and I won't be running this program on any other operating system. I will post more code here on this post for the time being. |
Arisotura |
| ||
Star Mario in this room you have a pile of apple pies Level: 163 Posts: 7202/9019 EXP: 56245944 Next: 241700 Since: 07-03-12 From: in a box Last post: 11 days ago Last view: 11 hours ago |
FinalShroom81 |
| ||
Member Hoogmin Level: 17 Posts: 36/56 EXP: 22626 Next: 2117 Since: 04-29-16 Last post: 2117 days ago Last view: 1347 days ago |
Here is all of my Terminal.h code
#pragma once
The error seems to be caused by line 10 of this file.#include <iostream> #include <string> #include "StringReverse.h" class Terminal { public: Terminal() {} ~Terminal(); static void Setup(); static void RenderMainMenu(); static void NavigateBasedOnSelection(std::string in); static void ResetBackToMainMenu(); static void RenderPreferencesMenu(); static void ColorSwitchBasedOnSelection(std::string in); static void BasicReset(); static void RenderWordReversal(); private: static void NotImplementedNotification(); static void DisplayDescription(); //Values to be passed into the system(); static std::string _gray; static std::string _blue; static std::string _lightGreen; static std::string _aqua; static std::string _lightAqua; static std::string _lightRed; static std::string _lightPurple; static std::string _yellow; //Full Description variable: static std::string _description; }; //All static members must be initialized outside of the class: std::string Terminal::_gray = "COLOR 8"; std::string Terminal::_blue = "COLOR 1"; std::string Terminal::_lightGreen = "COLOR A"; std::string Terminal::_aqua = "COLOR 3"; std::string Terminal::_lightAqua = "COLOR B"; std::string Terminal::_lightRed = "COLOR C"; std::string Terminal::_lightPurple = "COLOR D"; std::string Terminal::_yellow = "COLOR 6"; |
Arisotura |
| ||
Star Mario in this room you have a pile of apple pies Level: 163 Posts: 7203/9019 EXP: 56245944 Next: 241700 Since: 07-03-12 From: in a box Last post: 11 days ago Last view: 11 hours ago |
FinalShroom81 |
| ||
Member Hoogmin Level: 17 Posts: 37/56 EXP: 22626 Next: 2117 Since: 04-29-16 Last post: 2117 days ago Last view: 1347 days ago |
Posted by StapleButter If I remove that then a huge amount of errors will appear, according to the last time I tried but I will attempt it again. |
Arisotura |
| ||
Star Mario in this room you have a pile of apple pies Level: 163 Posts: 7204/9019 EXP: 56245944 Next: 241700 Since: 07-03-12 From: in a box Last post: 11 days ago Last view: 11 hours ago |
FinalShroom81 |
| ||
Member Hoogmin Level: 17 Posts: 38/56 EXP: 22626 Next: 2117 Since: 04-29-16 Last post: 2117 days ago Last view: 1347 days ago |
Posted by StapleButter So I tried your solution but It failed. I got 19 errors saying this: Error is LNK2005 Severity Code Description Project File Line Suppression State
Error LNK2005 "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Terminal::_lightGreen" (?_lightGreen@Terminal@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) already defined in CCHS_ShowcaseProgram.obj CCHS_ShowcaseProgram C:\Users\NIKE\Desktop\code projects\CCHS_ShowcaseProgram\CCHS_ShowcaseProgram\StringReverse.obj 1 |
Arisotura |
| ||
Star Mario in this room you have a pile of apple pies Level: 163 Posts: 7205/9019 EXP: 56245944 Next: 241700 Since: 07-03-12 From: in a box Last post: 11 days ago Last view: 11 hours ago |
FinalShroom81 |
| ||
Member Hoogmin Level: 17 Posts: 39/56 EXP: 22626 Next: 2117 Since: 04-29-16 Last post: 2117 days ago Last view: 1347 days ago |
Posted by StapleButter I will try. Thank you so much for all of the help you are giving me |
Arisotura |
| ||
Star Mario in this room you have a pile of apple pies Level: 163 Posts: 7206/9019 EXP: 56245944 Next: 241700 Since: 07-03-12 From: in a box Last post: 11 days ago Last view: 11 hours ago |
FinalShroom81 |
| ||
Member Hoogmin Level: 17 Posts: 40/56 EXP: 22626 Next: 2117 Since: 04-29-16 Last post: 2117 days ago Last view: 1347 days ago |
Posted by StapleButter I know the error has nothing to do with syntax so don't worry about that. The error has something to do with the Linker. |
FinalShroom81 |
| ||
Member Hoogmin Level: 17 Posts: 41/56 EXP: 22626 Next: 2117 Since: 04-29-16 Last post: 2117 days ago Last view: 1347 days ago |
Posted by StapleButter Hello StapleButter. I would like notify you with some good news. your solution worked and my program is up and running. Thank you so much for all of your help. I don't know of any way I can repay you. If you need help with something feel free to message me about it. |
Arisotura |
| ||
Star Mario in this room you have a pile of apple pies Level: 163 Posts: 7222/9019 EXP: 56245944 Next: 241700 Since: 07-03-12 From: in a box Last post: 11 days ago Last view: 11 hours ago |
Main - Computers and technology - Error C2084 visual C++ | Hide post layouts | New reply |
Page rendered in 0.102 seconds. (2048KB of memory used) MySQL - queries: 27, rows: 232/232, time: 0.015 seconds. Acmlmboard 2.064 (2018-07-20) © 2005-2008 Acmlm, Xkeeper, blackhole89 et al. |