|
Answer» Compiler shows me this, but I can't seem to see what I'm MISSING. main.cpp:45: error: expected `}' at end of input
There are two files this main.cpp and also a template at bottom:
#include//C++ standard library header file I/O definitions #include "file.h" //The template file file.h is included here using namespace std;//Contains classes, objects and functions in the C++ library - no std :: scope using namespace duram;//Resolves conflicting functions or variable names between the two libraries.
void instruct (void);
int main(int ARGC, CHAR ** argv)
{ instruct();
int a[7] = { -4, -2, 0, 2, 4, 6, 7 }; double b[7] = { -7.5, -4.3, 0, 6, 4.4, 8.2, 9.6 };
int v;
cout << "The integers in array a are: "; display(a,7); cout << "The real numbers in array b are: "; display(b,7); cout << "The integers smaller than 4 in a are: "; cout << count(a,7,v); cout << "The real numbers smaller than 4 in b are: "; cout << count(b,7,v);
return 0; }
void instruct(void) { cout << endl << endl << "This program utilizes initialized arrays full of 7 digits" << endl;//instructions for user cout << "and displays those array values using one template and" << endl;//instructions for user cout << "finds and returns the quantity of values within less than 4." << endl << endl;//instructions for user }
TEMPLATE file.h
#include using namespace std; namespace duram { template void display(T*a, int N){ for (int i=0; icout << a << " "; }
template<typename T> T count(T*a, int N, T v) { int counter = 0; for(int i=0; i<N; i++) { if (a<v) counter++; } return counter; }
It would seem that you have a mismatch of the {
Wen showing US code, use the code thing.
Code: [Select]{ template<typename T> void display(T*a, int N){ for (int i=0; i<N; i++) cout << a << " "; } Otherwise you turn on the formulating tokens used on tis SMF board. The code above looks like you have an extra { at the end of a line.
Code: [Select]#include<iostream> using namespace std; namespace duram { template<typename T> void display(T*a, int N){ <------------------------------------------ for (int i=0; i<N; i++) cout << a << " "; }
|