473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

[Linker error] undefined reference to `WinMain@16'...

1
Hey! When trying to compile the code for a ordered vector class I get the following error:
[Linker error] undefined reference to `WinMain@16'

Anyone have any idea what I might be doing wrong? I've been through this code multiple times and have no idea what would cause an error like this, I've never seen one like it before. Any help would be greatly appreciated.

The class is supposed to be able to create a sorted list of vectors of type Object. If an object is added to the list it places it in the proper order (ie you want to put in a 5 in the list 2 3 4 6, the 5 would be inserted between the 4 and 6)

Code is as follows:

Expand|Select|Wrap|Line Numbers
  1. #include <stdlib.h>
  2. #include <iostream>
  3. #ifndef _ORDEREDVECTOR_H
  4. #define _ORDEREDVECTOR_H
  5.  
  6. template <class Object>
  7. class orderedVector
  8. {
  9.     public:
  10.         orderedVector(int n);
  11.         orderedVector( );
  12.         orderedVector(const orderedVector & v);
  13.         virtual ~orderedVector( );
  14.         void dissolve ( );
  15.         void add (const Object x);
  16.         void remove (const Object x);
  17.         void removeAt (int i);
  18.         Object & operator [](int i);
  19.         int length( ) const;
  20.         bool isEmpty( ) const;
  21.         bool contains(const Object x);
  22.     private:
  23.         Object * buffer;
  24.         int size, capacity;
  25.         void reserve(int newCapacity);
  26.         void resize(int newCap) {reserve(newCap);}
  27.     };
  28.  
  29.     template <class Object>
  30.     orderedVector<Object>::orderedVector( ) :size(0),capacity(0),buffer(0){}
  31.  
  32.     template <class Object>
  33.     orderedVector<Object>::orderedVector(int n): size(0), capacity(n), buffer(0) 
  34.     {
  35.         if (n < 0)
  36.         {
  37.             cerr << "Error: You can't create a vector with a negative capacity!\n";
  38.             exit(1);
  39.         }
  40.     }
  41.  
  42.     template <class Object>
  43.     orderedVector<Object>::orderedVector(const orderedVector & v) 
  44.     {
  45.         if (this == &v) 
  46.         {
  47.             cerr << "Error: You can't copy a vector onto itself!\n";
  48.             exit(1);
  49.         }
  50.         buffer = 0;
  51.         buffer = new Object[v.capacity];
  52.         size = v.length( );
  53.         capacity = v.capacity;
  54.  
  55.         for (int i = 0; i < v.length( ); i++) 
  56.         {
  57.             buffer[i] = v.buffer[i];
  58.         }
  59.     }
  60.  
  61.     template <class Object>
  62.     orderedVector<Object>::~orderedVector( ) 
  63.     {
  64.         delete [ ] buffer;
  65.     }
  66.  
  67.     template <class Object>
  68.     void orderedVector<Object>::add(const Object x) 
  69.     {
  70.         if (size == capacity)
  71.                 resize(capacity + 5);
  72.  
  73.         if (size == 0)
  74.                 buffer[0] = x;
  75.         else 
  76.         {
  77.             for (int i = 0; i < size; i++) 
  78.             {
  79.                 if (x <= buffer[i])
  80.                 {
  81.                     int j = size;
  82.                     while (j > i) 
  83.                     {
  84.                         buffer[j] = buffer[j-1];
  85.                         j--;
  86.                     }
  87.                     buffer[i] = x;
  88.                 }
  89.             }
  90.         }
  91.         size++;
  92.     }
  93.  
  94.     template <class Object>
  95.     void orderedVector<Object>::remove(const Object x) 
  96.     {
  97.         bool temp;
  98.         for (i = 0; i < size; i++) 
  99.         {
  100.             if (buffer[i] == x)
  101.                 temp = true;
  102.             else
  103.                 temp = false;
  104.         }
  105.  
  106.         if (temp == false) 
  107.         {
  108.             cerr << "Error: Object doesn't exist!\n";
  109.             exit(1);
  110.         }
  111.  
  112.         else 
  113.         {
  114.             for (int i = 0; i < size; i++)
  115.             {
  116.                 int j = i;
  117.                 while (j < size - 1) 
  118.                 {
  119.                     buffer[j] = buffer[j+1];
  120.                     j++;
  121.                 }
  122.             }
  123.             size--;    
  124.         }
  125.     }
  126.  
  127.     template <class Object>
  128.     void orderedVector<Object>::removeAt(const int i) 
  129.     {
  130.         if (i < 0 || i >= size) 
  131.         {
  132.              cerr << "Error: Index out of range!\n";
  133.              exit(1);
  134.         }
  135.  
  136.         int j = i;
  137.         while (j < size - 1)
  138.         {
  139.                buffer[j] = buffer[j+1];
  140.             j++;
  141.         }
  142.         size--;
  143.    }
  144.  
  145.    template <class Object>
  146.    Object & orderedVector<Object>::operator [] (int i)
  147.    {
  148.         if (i < 0 || i >= size) 
  149.         {
  150.              cerr << "Error: Index out of range!\n";
  151.              exit(1);
  152.         }
  153.         return buffer[i];
  154.    }
  155.  
  156.    template <class Object>
  157.    int orderedVector<Object>::length( ) const 
  158.    {
  159.        return size;
  160.    }
  161.  
  162.    template <class Object>
  163.    bool orderedVector<Object>::isEmpty( ) const 
  164.    {
  165.        return size == 0;
  166.    }
  167.  
  168.    template <class Object>
  169.    bool orderedVector<Object>::contains(const Object x) 
  170.    {
  171.         bool temp;
  172.         for (i = 0; i < size; i++) 
  173.         {
  174.             if (buffer[i] == x)
  175.                 temp = true;
  176.             else
  177.                 temp = false;
  178.  
  179.         }
  180.         return temp;
  181.     }
  182.  
  183.     template <class Object>
  184.     void orderedVector<Object>::reserve(int newCap)
  185.     {
  186.         if (buffer == 0)
  187.         {
  188.             size = 0;
  189.             capacity = 0;
  190.         }
  191.  
  192.         if (newCap <= capacity)
  193.                 return;
  194.  
  195.         Object * newBuffer = new Object[newCap];
  196.  
  197.         for (int i = 0; i < size; i++)
  198.                 newBuffer[i]=buffer[i];
  199.  
  200.         capacity = newCap;
  201.         delete [ ] buffer;
  202.         buffer = newBuffer;    
  203.     }
  204. #endif
Sep 26 '05 #1
2 75759
Howzit going man,

I just saw your post...
I'm very sure you've already figured it out, but if you haven't its probably just that you have specified a int main() funtion in your project.

:)

Cheers,
Nic
May 16 '06 #2
Banfa
9,065 Expert Mod 8TB
SomethingRandom is definately on the right lines, however your main may be correct, you have tried to compile/link the project as a Windows Application without defining the WinMain function.

WinMain replaces main as the entry point for Windows Applications so either you were trying to right a Windows application and left out WinMain or you wern't trying to write a Windows application and (hopefully) have a main but have compile/link with flags that tell the compiler/linker that this is a Windows application and probably linked with some of the Windows system libraries.

P.S. The problem has nothing to do with the header file you have posted.
May 16 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: clusardi2k | last post by:
Hello, What can I do about these gcc Red Hat Linux errors. They are coming from the archive file. %gcc -I/usr/fltk -O2 -Wall -Wunused -fno-exceptions -I/usr/X11R6/include -o run main.o...
4
by: s_4 | last post by:
Witam! Mam maly problem... to chyba juz wszyscy wiedza... :-) do rzeczy: 1. zrobilem maly projekt i wywala mi takie bledy jak w tytule (tylko takie) 2. kompilujac kazdy plik z osobna nie ma...
4
by: Mark | last post by:
Hi, I'm trying to write some classes that kind of manage themselves. A linked list, that links different types of objects. Here's the code... object.h: --- class Object { int alt;
1
by: Oliver Bleckmann | last post by:
Damn, what's wrong here? CGI cgi; map<string,stringcgiParam = cgi.analyseCgiParam(); cout << cgiParam << endl; cout << cgiParam << endl; /////////////////////// #include <iostream>
0
by: Ehsan68 | last post by:
Hello my problem is "Linker Error: Undefined symbol _cga_driver_far in module maze.c " then Go to Options =>Linker =>Libraries This will display a box showing Container Class Turbo...
3
by: prakash.mirji | last post by:
Hello, I am getting below mention linker error when I tried to link my class test.C I use below command to compile test.C /usr/bin/g++ -g -fpic -fvisibility=default -D_POSIX_SOURCE...
2
by: kumarsatish | last post by:
The following C program in Turbo C is given the following error " Linker error:-Undefined Symbol _insert_point" #include<stdio.h> #include<conio.h> #define NULL 0 struct list_node
6
by: Ed Dana | last post by:
I'm trying to create a dynamic two dimensional array. My code looks like this: ====================================================================== #define DEF_FrameBuffer_H class FrameBuffer...
4
by: sanketiiit | last post by:
ERROR: Bloodshed Dev c++ undefined reference to cpu_features_init Perfect Solution to this error. If ( Installed MinGW ) then: 1. Uninstall MinGW 2. Delete manually MinGW Folder...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.