Skip to main content
Filter by
Sorted by
Tagged with
8 votes
1 answer
121 views

I have a template<int d> class Monomial and a template<int d> class Polynomial. Polynomial<d> owns a std::map<Monomial<d>, double>. I would like to create a member ...
BenPol's user avatar
  • 93
7 votes
1 answer
194 views

In C++, forward declarations introduce an incomplete type. Incomplete types can be used to declare pointers, but they cannot be used to initialize values or access members because the complete ...
Connor Lawson's user avatar
3 votes
1 answer
130 views

In order to hide template function definition in .cpp file, while having the forward declaration in a header file (function is used by a class template), the template has to be instantiated in order ...
Sergey Kolesnik's user avatar
1 vote
1 answer
55 views

I have this code on ADT specification of a node typedef int ElType; typedef node* Address; typedef struct node{ ElType info; Address next; } Node; Does it going to be the same if i do this? ...
Awafi's user avatar
  • 11
5 votes
2 answers
161 views

$ g++ --version Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 Apple clang version ...
ps_'s user avatar
  • 148
1 vote
1 answer
91 views

Consider a pair of classes which represent the same thing in Python and each implements a method that converts one to the other. As an example consider transforming from cartesian to polar coordinates ...
roschach's user avatar
  • 9,616
0 votes
1 answer
162 views

Let's suppose I want to declare structs A and B struct A{ B toB(){ return B(); } }; struct B{ A toA(){ return A(); } }; I'll get an error that type B is undefined main.cpp:2:2: error: ...
BlobKat's user avatar
  • 320
0 votes
1 answer
274 views

I am trying understand how I can declare, in a nim source, different procedures that call each other, as it sounds like the compiler expects all calls to come after the declaration, but the procedures ...
GiMS_Pang's user avatar
-1 votes
1 answer
191 views

I have looked at a significant number of posts regarding forward declarations/PIMPL, but haven't quite managed to get it to work with the external libraries I'm using. I want to create a shared ...
RPH's user avatar
  • 129
0 votes
0 answers
156 views

As for a minimally reproducible example, say I have the following class A defined in a header file a.h: // file a.h #include <cstdio> class A { private: int val; public: A(int aVal) { ...
River's user avatar
  • 1
4 votes
0 answers
199 views

In a header file of a large project, I have to forward declare a function template before the calling site. The code boils down to this: //H1.h #pragma once template <typename> void f(); ...
zwhconst's user avatar
  • 1,647
-2 votes
2 answers
137 views

The following https://godbolt.org/z/5qd8WbYz9 doesn't work and after reading the duplicate I thought I would have to define an custom deleter However, I managed to get it working https://godbolt.org/z/...
Tom Huntington's user avatar
3 votes
3 answers
538 views

I run into the following problem and idk if it can be solved in an elegant way: I need to statically initialize an interface wifi and sntp in main. I can't do it in global space because they are ...
glades's user avatar
  • 5,356
3 votes
1 answer
109 views

I have a template that is just that - a very basic class template; something like: Tmpl.h template <typename Base> class Tmpl: public Base { public: Tmpl(): Base() { this->...
codeling's user avatar
  • 11.5k
1 vote
1 answer
170 views

I have two classes, A and B, which depend on each other: class A { public: B* b; A() { b = new B(); } }; class B { public: A* a; B() = default; }; This code will not ...
Nirvana's user avatar
  • 663
-1 votes
3 answers
418 views

Sorry if this has been asked before; I found similarly titled questions, but none of them focused on the same aspects I'm having trouble with. There's a class A, and a class B that should only be ...
the-baby-is-you's user avatar
0 votes
1 answer
75 views

So, read clearly... // scene.h #include "Entity.h" class Scene { public: Entity createEntity() { return Entity(this); } }; So, that was the Scene class, then we've got the ...
Anuhas's user avatar
  • 9
2 votes
1 answer
193 views

For example, given the following: // enum.h enum class TestEnum: int { ONE, TWO, THREE }; // function.h enum class TestEnum: int; int TestFunction(TestEnum te = TestEnum::THREE); // ...
MisterOfficer_234's user avatar
1 vote
1 answer
310 views

Consider the following scenario: "A.cpp": void fun() { std::cout << "fun() global\n"; } "B.cpp": namespace N { void f() { std::cout << "...
CinCout's user avatar
  • 9,629
3 votes
1 answer
259 views

I have got this hpp file: struct rte_spinlock_t; class A { public: void init(); private: rte_spinlock_t* spinlock; }; and the corresponding cpp file: #include "A.hpp&...
Antonio Di Bacco's user avatar
2 votes
1 answer
196 views

Does the standard (as of C++20) explicitly or implicitly allow using a different class-key when (forward-)declaring a class-name than when defining it? For the purpose of this question class-key shall ...
bitmask's user avatar
  • 35.2k
0 votes
0 answers
999 views

I am doing a project where I recreate Pokémon in C++ and currently I am in the process of implementing moves. My implementation is currently: #pragma once class Pokemon; class MoveBase { public: ...
Legoshark's user avatar
0 votes
1 answer
146 views

Please consider the following working code from __future__ import annotations class A(object): def __init__(self, val: int): self.val = val @property def b(self) -> B: ...
Gulzar's user avatar
  • 28.7k
1 vote
1 answer
613 views

I see this question has been discussed in various places, e.g. here,here,here and here .But, i have still not been able to relate to the questions aforementioned. My situation: I am trying to ...
warrior_monk's user avatar
2 votes
2 answers
132 views

In my header file, foo.h, I have: #ifdef __cplusplus extern "C" { #endif int foo(int x); #ifdef __cplusplus } #endif Now, in foo.cpp, should I also use extern "C", and define: #...
einpoklum's user avatar
  • 137k

1
2 3 4 5
22