473,722 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 75791
SomethingRandom
1 New Member
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 Recognized Expert Moderator Expert
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
39211
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 -L/user/fltk/lib -lfltk_images -lfltk -lpng -ljpeg -lz -L/usr/X11R6/lib -lm -lXext -lX11 -lsupc++ chris.a -lpci -lm -lccur_rt -lrt
4
7566
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 bledow, ale kompilujac caly projekt to wystepuja powyzsze bledy 3. specjanie na potrzeby tego postu mocno okroilem moj projekt i nadla wywala ten sam blad tylko w trzech miejscach, a nie w stu piedziesieciu
4
5876
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
2707
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
3477
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 Version
3
11597
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 -DTRACING - D__EXTENSIONS__ -D__RWCOMPILER_H__ -D_REENTRANT -D_RWCONFIG=8s - D_RWCONFIG_12d -D_RWSTDDEBUG -DRWDEBUG -o test1 test1.o -L/lib -
2
3514
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
3529
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 { public: FrameBuffer(int prmWidth, int prmHeight, unsigned long prmPen); FrameBuffer(int prmWidth, int prmHeight);
4
19736
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 (C:\\ folder) 3. happy coding I can understand the frustration, as i had with this error.
0
9384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.