Garmaine Staff asked 1 year ago

The little code I have compiles fine but when I go to run IntVector.cpp I get literally thousands of warnings like the following:

 IntVector:3:1533: warning: null character ignored [-Wnull-character]
  ...<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>
 IntVector:8:3: warning: null character ignored [-Wnull-character]
<U+0008><U+0000><U+0000><E9><U+0000><U+0000><U+0000><U+0000>H<8D>E<D0>H...
 ?IntVector:9:2415: warning: null character ignored [-Wnull-character]
  ...<U+0000><U+0000><9E><U+0000><U+0000><U+0000>|<U+0003><U+0000><U+0000>...

And so on. This is my first time trying to run a C++ program so I suppose the problem could be in my setup. I'm on Mac and using Emacs to code and compile and terminal to run it.

IntVector.cpp

#include <iostream>
#include "IntVector.h"
#include <cmath>
using namespace std;


  int* array = new int[0];
  int num_elements;
  int array_size;
  int expansion_factor;

void IntVector::expandArray(){

  }
void IntVector::add(int val){

    cout << "Hello"; 
  }
void IntVector::remove(int index){   
  }
int IntVector::get(int index) const{
    return index;
  }
void IntVector::removeLast(){
  }
void IntVector::set(int index, int val){
  }

std::string IntVector::toString()const {
    return "";
  }

IntVector::IntVector(int initial_size){

  }

IntVector:: ~IntVector(){}


int main(){

  IntVector v(5);
  v.add(5);

}

IntVector.h

#ifndef INTVECTOR_H_
#define INTVECTOR_H_

using std::cout;
class IntVector {
private:
  int* array;
  int num_elements;
  int array_size;
  int expansion_factor;
  void expandArray();
 public:
  void add(int val);
  void remove(int index);
  int get(int index) const;
  void removeLast();
  void set(int index, int val);
  std::string toString() const;
  IntVector(int initial_size);
  ~IntVector();


};
#endif