Two errors that I can't figure out (WHY!)
Dec 18, 2015 at 2:29am UTC
Okay guys I'm getting 2 weird errors. If you look at the commented part within my code you'll see what I mean. It has to deal with curly bracket errors? I wrote down what the compiler says about it next to the line of code.
Thanks for the help guys.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
#include <iostream>
#include <string>
#include <AbdominalPain.h>
using namespace std;
AbdominalPain::AbdominalPain()
{
void AbdPainIs(){ // error here: A function definition is not allowed here
//before '{' token
int acuteOrBeganSudd = 1;
int burning = 2;
int ChronicOrOnGoing = 3;
int crampy = 4;
int dull = 5;
int gnawing = 6;
int intense = 7;
int intermittentOrEpisodic = 8;
int worseningOrProgressing = 9;
int sharp = 10;
int steady = 11;
int abdAnswer;
cout << "Lets look more into this symptom" << endl;
cout << " " << endl;
cout << "REVIEW THESE SYMPTOMS" << endl;
cout << "1) Acute or began suddenly" << endl;
cout << "2) Burning" << endl;
cout << "3) Chronic or on-going" << endl;
cout << "4) Crampy" << endl;
cout << "5) Dull" << endl;
cout << "6) Gnawing" << endl;
cout << "7) Intense" << endl;
cout << "8) Intermittent or episodic" << endl;
cout << "9) Worsening or progressing" << endl;
cout << "10) Sharp" << endl;
cout << "11) Steady" << endl;
cout << "What's your pain out of this list? " << endl;
cin >> abdAnswer;
cout << " " << endl;
if (abdAnswer == 1){
}
else if (abdAnswer == 2){
}
else if (abdAnswer == 3){
}
else if (abdAnswer == 4){
}
else if (abdAnswer == 5){
}
else if (abdAnswer == 6){
}
else if (abdAnswer == 7){
}
else if (abdAnswer == 8){
}
else if (abdAnswer == 9){
}
else if (abdAnswer == 10){
}
else if (abdAnswer == 11){
}else {
cout << "Go see your physician." << endl;
cout << "It might be something serious." << endl;
}
}
// pain located in
void AbdPainLocated(){
int abdominalButRadiatesToOtherPartsOfBody = 1;
int lowerAbdomen = 2;
int middleAbdomen = 3;
int oneOrBothSides = 4;
int upperAbdomen = 5;
int AbdPainLocAnswer;
cout << "PAIN LOCATION?" << endl;
cout << "1) Abdominal but radiates to other parts of body" << endl;
cout << "2) Lower abdomen" << endl;
cout << "3) Middle abdomen" << endl;
cout << "4) One or both sides" << endl;
cout << "5) Upper abdomen" << endl;
cout << "Location? " ;
cin >> AbdPainLocAnswer;
if (AbdPainLocAnswer == 1){
}
else if (AbdPainLocAnswer == 2){
}
else if (AbdPainLocAnswer == 3){
}
else if (AbdPainLocAnswer == 4){
}
else if (AbdPainLocAnswer == 5){
}else {
cout << "See your doctor" << endl;
}
}
// triggered or worsened by
void AbdTriggeredby(){
int coughingOrOtherJarringMovements = 1;
int drinkingAlcohol = 2;
int eatingCertainFoods = 3;
int menstrualCycle = 4;
int stress = 5;
int AbdTrigBy;
cout << endl;
cout << "TRIGGERED BY?" << endl;
cout << "1) Coughing or jarring movements" << endl;
cout << "2) Drinking alcohol" << endl;
cout << "3) Eating certain foods" << endl;
cout << "4) Menstrual cycle" << endl;
cout << "5) Stress" << endl;
cout << "Selection: " ;
cin >> AbdTrigBy;
if (AbdTrigBy == 1){
}
else if (AbdTrigBy == 2){
}
else if (AbdTrigBy == 3){
}
else if (AbdTrigBy == 4){
}
else if (AbdTrigBy == 5){
}else {
cout << "See the doctor" << endl;
}
}
// accompanied by (CANCEL THIS)
void AbdAccompaniedBy(){
int abdominalSwelling = 1;
int blackOrBloodyStools = 2;
int constipation = 3;
int diarrea = 4;
int fever = 5;
int inablilityToMoveBowelsInSpiteOfUrge = 6;
int nauseaOrVomiting2 = 7;
int passingGas = 8;
int pulsingSensationNearTheNaval = 9;
int rash = 10;
int stomachGrowlingOrRumbling = 11;
int unintendedWeightLoss = 12;
int accomBy;
string answer2;
cout << endl;
cout << "Is your side affects accompanied by something else?(Y/N) " ;
cin >> answer2;
if (answer2 == "Y" || answer2 == "y" ){
cout << "ACCOMPANIED BY?" << endl;
cout << "1) Abdominal swelling" << endl;
cout << "2) Black or bloody stools" << endl;
cout << "3) Constipation" << endl;
cout << "4) Diarrhea" << endl;
cout << "5) Fever" << endl;
cout << "6) Inability to move bowels" << endl;
cout << "7) Nausea or vomiting" << endl;
cout << "8) Passing gas" << endl;
cout << "9) Pulsing sensation near naval" << endl;
cout << "10) Rash" << endl;
cout << "11) Stomach growling or rumbling" << endl;
cout << "12) Unintended weight loss" << endl;
cout << "Selection: " ;
cin >> accomBy;
if (accomBy == 1){
}
else if (accomBy == 2){
}
else if (accomBy == 3){
}
else if (accomBy == 4){
}
else if (accomBy == 5){
}
else if (accomBy == 6){
}
else if (accomBy == 7){
}
else if (accomBy == 8){
}
else if (accomBy == 9){
}
else if (accomBy == 10){
}
else if (accomBy == 11){
}
else if (accomBy == 12){
}else {
cout << "See the doctor" << endl;
}
}else {
}
}
} // error here: expected '}' at the end of input
/*
AbdominalPain::~AbdominalPain()
{
//dtor
}
*/
Dec 18, 2015 at 2:32am UTC
I can imagine that both of your errors are arising from here:
1 2 3 4 5 6
AbdominalPain::AbdominalPain()
{
void AbdPainIs(){ // error here: A function definition is not allowed here
//before '{' token
int acuteOrBeganSudd = 1;
int burning = 2;
You're trying to define a function inside of your constructor (another function). C++ does not allow this.
Dec 18, 2015 at 2:38am UTC
Not only there but close to the end of it as well.
That's what I thought it was about but wanted to make 100% sure.
Dec 18, 2015 at 11:52am UTC
Like Zombie dude said, the problem at the end stems from the local function (perhaps you've seen code for a compiler that allows this), The first curly brace needs a closing brace, so no doubt you'll have 2 sets of errors
Topic archived. No new replies allowed.