What happens when you hi-light a header file then push Delete Key?

I am using visual studio 2013
I hi-lighted a header file (CandyBox.h) in Solution Explorer and hit the delete key.
The file is gone in the folder.
So I thought that the code below should not compile and run.
But much to my surprise it compiles and runs just fine even after I got rid of the header.

How can this be? Where did that file go? Where is Visual Studio getting my class definition from. When the file is not there?

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
#include <iostream>                    // For stream I/O
#include <cstring>                     // For strlen() and strcpy()
#include "CandyBox.h"                  // For CBox and CCandyBox
using std::cout;
using std::endl;


int main()
{
  CBox myBox(4.0, 3.0, 2.0);                     // Create CBox object
  CCandyBox myCandyBox;
  CCandyBox myMintBox("Wafer Thin Mints");       // Create CCandyBox object

  cout << endl
       << "myBox occupies " << sizeof myBox      // Show how much memory
       << " bytes" << endl                       // the objects require
       << "myCandyBox occupies " << sizeof myCandyBox
        << " bytes" << endl
       << "myMintBox occupies " << sizeof myMintBox
       << " bytes";

  cout << endl
       << "myBox length is " << myBox.m_Length;

  myBox.m_Length = 10.0;

  // myCandyBox.m_Length = 10.0;       // uncomment this for an error

  cout << endl;
  return 0;
}
Last edited on
Has the file actually been deleted? Have you opened up a file explorer, outside of Visual Studio, and searched for the file on disk?
Yes I looked at the folder in Windows Explorer.
There is definitely no file named CandyBox.h anywhere in that project folder.
But it still builds and runs. I even altered the text slightly to make sure it was recompiling.

Is the file anywhere at all on your hard drive? The search path for headers is not just the current directory.
I forgot to mention that I had originally dragged and dropped the file from a windows folder into solution explorer.
I can see from reading the file CL.read.1.tlog inside of my visual studio folder that it includes a reference to the absolute path of the CandyBox.h header file from its original source which is outside of the project directory. (The file still does exist at that location.)

Maybe that explains why it still builds.

But it doesn't answer the question, what happens when I hi-light a file and then hit delete.



Last edited on
Ok I think i figured out the answer if you hi-light and delete and it exists in the folder of the project you get a prompt that gives you the option to remove or delete. That works pretty self explanatory. And does what it is expected to do.

The thing I cannot figure out is if the file you hi-lighted a file and then removed, but not permanently deleted, what happens. Where are the instructions to keep using it. It becomes invisible in solution explorer, but still builds. It keeps getting included in that CL.read.1.tlog file. WHY??? I understand I can just delete it permanently but I want to do it from within visual studio and I want to understand what is happening.

Maybe it will be helpful to explain why I want to do this.

I want to have part of my program removed. I want to see that the program does not compile and then I want to include the removed portion via DLL file and see that it compiles.

I don't understand how to remove it properly from within visual Studio.
Last edited on
It becomes invisible in solution explorer, but still builds.


Because solution explorer has nothing at all to do with the build process. The build process happens at the command line, using a command line executable. Solution explorer is a helpful way for you to organise your files.
thank you
Topic archived. No new replies allowed.