Answer the question
In order to leave comments, you need to log in
How to divide a project into elements in Vusial studio and then make them one whole?
In general, I need to implement a large project, and it’s inconvenient to do everything about one element (I’m afraid to get confused) and I would like to somehow separate the project. For example, something in one element would be main and in another function.
Answer the question
In order to leave comments, you need to log in
Do you mean to split the project into several files?
You will need to create two files for each module: a header file (with declarations) and the actual implementation (definition) file. Declaration files have the extension .h .H .hpp and so on.
main.cpp: definition of the main function.
// Следующая строка при компиляции будет заменена на содержимое файла helloworld.h
#include "helloworld.h"
int main(int argc, char** argv)
{
helloworld(); // Вызываем функцию определённую в другом файле.
return 0;
}
// Следующая конструкция называется include guard.
// Благодаря ней вы не сможете вставить содержимое этого файла дважды,
// что поможет вам избежать ошибок переопределения.
#ifndef HELLOWORLD_H
#define HELLOWORLD_H
// Объявление функции.
// Если функция объявлена но не определена в данном файле,
// компилятор будет искать её реализацию в других файлах.
void helloworld();
#endif
// Снова вставляем содержимое файла helloworld.h
#include "helloworld.h"
#include <iostream>
// Определяем функцию.
void helloworld()
{
std::cout << "Hello, world!";
}
Mmmm .. Of course, I could be wrong, but it seems to be called OOP :)
Object-Oriented Programming (C# and Vi...
Recording of a seminar on the topic "What is OOP and what is it with ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question