c++ - Error LNK1561: entry point must be defined- main() exists -


i know question has been posted elsewhere, , i've tried solutions, error lnk1561 , have no clue causing problem. program calculates , prints largest, smallest, average, , sum of sequence of numbers user enters. questions or if need more info, ask.

    #include <iostream>     #include <climits>     using namespace std;      template <class t>     t dataset(t &sum, t &largest, t &smallest, t avg);      template <class t>     int main(){         cout << "this program calculates , prints largest, smallest,"              << endl << "average, , sum of sequence of numbers user enters." << endl;         t avg, sum, largest, smallest;         avg = dataset(&sum, &largest, &smallest, avg);         cout << "the largest of sequence entered is: " << largest << endl;         cout << "the smallest of sequence entered is: " << smallest << endl;         cout << "the sum of sequence entered is: " << largest << endl;         cout << "the average of sequence entered is: " << avg << endl;         return 0;     }     template <class t>     t dataset(t &sum, t &largest, t &smallest, t avg){         t num;         signed long long int max = llong_min, min = llong_max;          int count;         do{             cout << "enter sequence of numbers: (^z quit) ";             cin >> num;             if(cin.good()){                 count++;                 sum += num;                 if(num > max)                     max = num;                 if(num < min)                     min = num             }             else if(!cin.good()){                 cout << "error. try again.";             }         }while(!cin.eof());         avg = sum / count;         return avg;     } 

main() can‘t template. you‘ll have drop template <class t> line before it, , instantiate dataset using specific type such double, example:

// no template <class t line> int main(){     cout << "this program calculates , prints largest, smallest,"          << endl << "average, , sum of sequence of numbers user enters." << endl;     double avg, sum, largest, smallest;     avg = dataset(sum, largest, smallest, avg); … 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -