Skip to main content
0 votes
4 answers
118 views

How to encapsulate a for clause?

This is more like an exercise. I have several conditions that affect 2 nested for clauses: for(...)//1st { for(...)//2nd { ... } } and since there are various possibilities (each one ...
Patrick's user avatar
  • 2,623
-3 votes
1 answer
95 views

How can I pass a reference to an internal class upon construction of a public-facing subclass without violating nullabe safety?

I'm not super experienced with C#, and this is a bit of a puzzle. Consider the following code: #nullable enable using System.Collections.Generic; // Biology.dll public abstract class Animal { ...
suszterpatt's user avatar
  • 8,317
0 votes
1 answer
98 views

How to access function members in a unit test without exposing them to the client? [duplicate]

I am working on a project in C++. I am writing several unit tests, and I have functions exposed publicly so I can access them in my unit test target executables, but I really don't want them exposed. ...
JAYD3V's user avatar
  • 12.5k
3 votes
1 answer
138 views

How to properly implement polymorphism with base class pointers in C++?

I'm learning Object-Oriented Programming in C++ and trying to understand polymorphism with base class pointers. I created a base class Animal and a derived class Dog, both with a speak() method. I ...
Hassan Ali's user avatar
3 votes
2 answers
107 views

How to instantiate a struct containing many private properties in a separate module without using a constructor function?

I want the user to be able to pass the struct along and instantiate it without a constructor function, but not be able to modify the structure's fields without using the setter methods provided in the ...
GrimOutlook's user avatar
2 votes
1 answer
113 views

How to implement abstraction/encapsulation; like a generic/opaque struct that holds a platform specific window

typedef struct { WindowData data; bool vsync; } Window; typedef struct { Window window; GLFWwindow *native_window; } WindowsWindow; Window *windowCreate(const WindowProperties props,...
Aidan's user avatar
  • 87
0 votes
1 answer
116 views

OOAD Head First --Encapsulation

public class Guitar { private String SerialNumber ; private double Price; private String Model; private Type Type; private Builder Builder; private Wood BackWood; private ...
KAAMIRLI's user avatar
1 vote
1 answer
50 views

Why do private fields not get overridden in subclasses?

I'm trying to create a parent class A with a private field #abc and a subclass B that overrides this field. However, when I call methods from the parent class that access the private field, it still ...
pery mimon's user avatar
  • 8,439
-7 votes
1 answer
108 views

Is making an enum public disrespecting encapsulation?

This is a question for an assignment for Uni. For this assignment we have to respect encapsulation and inheritance in Java. The important classes to know right now are: Cliente Class import java.util....
MiguelPereira3530's user avatar
-4 votes
1 answer
99 views

Pass a reference to a sensor or create the sensor object in the class [closed]

Note to SO. If I ask this question to AI I get a very similar output as the accepted reply. Without out all the questions about how I asked the question. Just sayin. I am using this class for ...
WouldRatherBuildAMotor's user avatar
1 vote
0 answers
88 views

How to convert between children types when inheriting privately

Consider this piece of C++ code: template <typename T> struct Base { // data members ... // conversion constructors: template <typename U> Base(const Base<U>& ...
lobelk's user avatar
  • 531
0 votes
1 answer
111 views

how to make a structure defined in a NVM AUTOSAR module invisible for the application in C?

There is a requirement in the AUTOSAR NVM module that says: [SWS_NvM_00135] The Administrative block shall be invisible for the application and is used exclusively by the NvM module for security and ...
Ehsan R's user avatar
  • 63
2 votes
2 answers
127 views

Does shared objects breaks encapsulation?

The encapsulation principle says : "You should hide the attributes of your class and only make them accessible via methods. This guarantees the validity of class invariants." I'm totally ...
xerox0213's user avatar
0 votes
1 answer
179 views

Encapsulate third-party Service Provider Interface

I am trying to encapsulate a third-party library by writing a wrapper over it and using only required APIs as per my need. To achieve this, I have created this wrapper project as a standalone project ...
booyaakaashaa's user avatar
3 votes
1 answer
100 views

Encapsulation of inline reified method in kotlin

I have written the util class to be used with Flow<> in kotlin. The goal of the class is to simplify error handling and make possible to instantly finish the flow by calling breakFlow() method. ...
K0cur's user avatar
  • 120

15 30 50 per page
1
2 3 4 5
138