Questions tagged [abstraction]

Abstraction is a computer science concept in which an implementation is separated from its interface.

Abstraction is a computer science concept in which an implementation is separated from its interface. Abstraction allows an implementation to be modified without changing the interface, so that other code which relies on this interface does not have to be modified.

For instance, a function prototype in C would be considered the function's interface, and its definition is considered the implementation. The function definition can change (for instance, to improve performance or fix a bug), but as long as the function signature (as specified by the prototype) is the same, any code calling the function can remain the same.

1026 questions
-4
votes
3 answers

Is it correct to have a const function which modified a 'scratchpad' variable?

I'll describe the problem. I have a class with API, which invokes a large hierarchy of class member functions to do some logic. Now, I updated the logic so each function in the hierarchy requires an extra argument (the API did not change). A…
Elad Weiss
  • 3,140
  • 3
  • 13
  • 37
-4
votes
1 answer

Casting between types

I have an abstract class for Serializing data as follows template class Serialize{ public: virtual string serialize() = 0; virtual T deSerialize(string value) = 0; } I also have a data model a follows class…
Arnold Zahrneinder
  • 3,368
  • 4
  • 28
  • 54
-4
votes
2 answers

Why we can't instantiate abstract class of non abstract methods in it?

We know we can't instantiate an abstract class as it is incomplete. But why can’t we instantiate a class with no abstract methods in it which is marked as abstract? Is there any reason for that?
-5
votes
1 answer

Virtual functions "Shape" Assignment

I can't seem to get my cylinder class to properly perform its print and volume functions. Here are the instructions for the assignment: Design a class named Shape which is an abstract base class. Shape has two pure virtual functions, printShapeName…
-5
votes
2 answers

c# making object in different ways (abstraction used)

I have made two objects, i don't know what is the difference between them also. Is anyone count as a good practice? examples are appreciated! also, mark the advantages of both. Is it that I making a very simple code that's why I'm not seeing the…
Hassaan Raza
  • 83
  • 10
-5
votes
1 answer

Is this a valid code for achieving abstraction in java using abstract classes and abstract methods

Is this a correct method to achieve abstraction? As this in the abstract class public abstract class Employee { private String name, address; int basicSalary; public String getName(){ …
Anupam
  • 13
  • 4
1 2 3
68
69