| | |
find the error
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2008
Posts: 55
Reputation:
Solved Threads: 0
i cant seem to find what is wrong with this piece of code:
looks good to me-but my hw says it has an error in the code.
looks good to me-but my hw says it has an error in the code.
C++ Syntax (Toggle Plain Text)
struct TwoVals { int a = 5; int b = 10; }; int main() { TwoVals varray[1]; varray.a[0] =1; return0; }
Last edited by afg_91320; Nov 18th, 2008 at 2:00 pm.
•
•
•
•
well i did try
i think its missing:
#include <iostream>
using namespace std;
but i dont see any other errors
While NinjaLink probably fixed one of the errors by accident, you should still refrain from following his advice verbatim as it would only add more confusion to the mix by requiring a different header and opening you up to portability concerns.
And as a show of good faith, I'll point out two of the errors (which are actually caused by the same mistake):
struct TwoVals
{
int a = 5;
int b = 10;
}; C++ Syntax (Toggle Plain Text)
struct TwoVals { int a; int b; TwoVals ( int init_a = 5, int init_b = 10 ) : a ( init_a ), b ( init_b ) {} };
I'm here to prove you wrong.
•
•
Join Date: Oct 2008
Posts: 23
Reputation:
Solved Threads: 2
C++ Syntax (Toggle Plain Text)
struct TwoVals { int a; int b; }; int main() { TwoVals varray[ 1 ]; varray[ 0 ].a = 1; }
Or you can do as Narue said.
![]() |
Similar Threads
- program error for cd burner program (Windows NT / 2000 / XP)
- runtime error#58 (Visual Basic 4 / 5 / 6)
- Can't find the error (C)
- help me find the error (C++)
- runddl32 error not responding (Windows NT / 2000 / XP)
- find out the error in my code (Java)
- Lotus notes error: #0c:04 (Networking Hardware Configuration)
- Bridge.dll error (Viruses, Spyware and other Nasties)
- iexplorer.exe send error reports(1 too many) (Web Browsers)
Other Threads in the C++ Forum
- Previous Thread: Finding the percentage of unique numbers in an array.
- Next Thread: pointers to chars
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






