unresolved external

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Heap
// Demonstrates dynamically allocating memory

#include <iostream>
using namespace std;

int* itOnHeap(); // returns an it on the heap
void leak1(); // creates a memory leak
void leeak2(); // creates another memory leak

int main()
{
	int* pHeap = new int;
	*pHeap = 10;
	cout << "*pHeap: " << *pHeap << "\n\n";

	int* pHeap2 = itOnHeap();
	cout << "*pHeap2: " << *pHeap2 << "\n\n";

	cout << "Freeing memory pointed to by pHeap.\n\n";
	delete pHeap;

	cout << "Freeing memory pointed to by pHeap2.\n\n";
	delete pHeap2;

	// get rid of dangling pointers
	pHeap = 0;
	pHeap2 = 0;

	return 0;
}

int* intOnHeap()
{
	int* pTemp = new int(20);
	return pTemp;
}

void leak1()
{
	int* drip1 = new int(30);
}

void leak2()
{
	int* drip2 = new int(50);
	drip2 = new int(100);
	delete drip2;
}


I can't see the error, anyone any ideas? Cheers!
1
2
3
4
5
int* itOnHeap(); // returns an it on the heap // line 7
...
// int* intOnHeap() // *********  line 33
int* itOnHeap()
{
Cheers!
Topic archived. No new replies allowed.