Error help

So I have errors that i`m not understanding why they are there. I need help ASAP
Errors:
line 24, 'source' was not declared in this scope
line 32, no matching function for call to 'Numbers::resize(std::size_t)'
line 36, prototype for 'void Numbers::resize(long unsigned int' does not match any class in 'Numbers'
line 9, candidate is: void Numbers::resize()

All of my code below.

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <algorithm>

using namespace std;

class Numbers
{
 	public:
                Numbers();
		~Numbers();
		void insert(const unsigned long& item);
		void resize();
		void display();
		void remove_last();
		void operator = (const Numbers& source);
	private:
		unsigned long  * data;
		std::size_t used;
		std::size_t capacity;
};

Numbers::Numbers(){
	data = new unsigned long[source.capcity];
	capacity = source.capacity;
	used = source.used;
	std::copy(source.data, source.data + used, data);
	
}
void Numbers::insert(const unsigned long& item){
	if (used == capacity)
	resize(used + 1);
	data[used] = item;
	++used;
}
void Numbers::resize(unsigned long new_capacity){
	unsigned long * tmp;
	if (new_capacity == capacity)
		return;
	if (new capacity < used)
		new_capacity = used;
	tmp = new unsigned long[new_capacity];
	std::copy( data, data + used, tmp);
	delete [] data;
	data=tmp;
	capacity = new capacity;
}
void Numbers::remove_last(){
	delete []data;
}
void Numbers::operator=(const Numbers& source){
  if(&source==this)return;
	delete[]data;
	capacity=source.capacity;
	used=source.used;
	data=new unsigned long[capacity];
	std::copy( source.data, source.data+used, data);
}
Numbers::~Numbers(){
	delete[]data;
	std::cout<<"I`m melting!"<<endl;
}
void Numbers::display(){
	for(size_t i=0; i < used; i++){
		cout << data[i]<<' ';
	}
}
your line numbers don't correspond

'source' was not declared in this scope
1
2
Numbers::Numbers(){
	data = new unsigned long[source.capcity];  //¿what's source? 


no matching function for call to 'Numbers::resize(std::size_t)'
candidate is: void Numbers::resize()
void resize(); //you said that resize doesn't takes parameters
Topic archived. No new replies allowed.