1 Replies - 226 Views - Last Post: 05 February 2018 - 07:53 PM Rate Topic: -----

#1 derekromania  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-January 18

Are there other ways of writing this code [c and c++]

Posted 05 February 2018 - 07:06 PM

I'm trying to change this code by writing it in different methods. I tried to remove the destructor and std::ofstream::out flag but i got errors. I had this error :

(error LNK2019: unresolved external symbol "public: __thiscall Logger::~Logger(void)" ([email protected]@[email protected]) referenced in function "void __cdecl `dynamic atexit destructor for 'testing''(void)" ([email protected]@YAXXZ)
)





#include <iostream>
#include <string>
#include <fstream>
#include <vector>

using namespace std;
std::ofstream ofs;

void showSelection();
void bookMovie(moviee& date, showtime& pBook);
Logger testing; 

Logger::Logger()
{

    lognum = 0;
    ofs.open("test.txt", std::ofstream::out | std::ofstream::app);
}

Logger::~Logger()
{

    ofs.close();
}




Is This A Good Question/Topic? 0
  • +

Replies To: Are there other ways of writing this code [c and c++]

#2 tony jay  Icon User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 50
  • Joined: 31-January 18

Re: Are there other ways of writing this code [c and c++]

Posted 05 February 2018 - 07:53 PM

Look at line 11
11 Logger testing;



Testing is a variable of type Logger, but there is no type logger!

I see a constructor and a destructor that could be part of a class or struct called logger, but there is no class or struct called logger and hence no type called logger.
I suggest that you review what a class or a struct actually is and how they are used in C (struct only) and C++ (struct and C++).

This site has 4 good tutorials on classes and structs and how to make user-defined types.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1