Questions tagged [member]

A member is an element of an object in the object-oriented programming paradigm.

A member is an element of an object in the object-oriented programming paradigm. Member variables are often called fields, while member functions are also called methods.

1754 questions
19
votes
2 answers

"No appropriate default constructor available"--Why is the default constructor even called?

I've looked at a few other questions about this, but I don't see why a default constructor should even be called in my case. I could just provide a default constructor, but I want to understand why it is doing this and what it affects. error C2512:…
AAB
  • 674
  • 3
  • 14
  • 27
18
votes
2 answers

How can I create a read-only class member in Scala?

I want to create a Scala class where one of its var is read-only from outside the class, but still a var. How can I do it? If it was a val, there was no need to do anything. By default, the definition implies public access and read-only.
18
votes
2 answers

enable class's member depending on template

I already know that you can enable (or not) a class's method using std::enable_if for exemple: template class Field { ... size_t offset(const std::array& p) const { ... } template
Amxx
  • 3,020
  • 2
  • 24
  • 45
17
votes
5 answers

getter and setter for class in class c#

Assuming we have a class InnerClass with attributes and getter/setter. We also have a class OuterClass containing the InnerClass. e.g. class InnerClass { private int m_a; private int m_b; public int M_A { get { …
DummyCSharp
17
votes
8 answers

Accessing a protected member variable outside a class

I'm querying for the ID of a field by accessing a class function which someone has already put in place. The result is a object returned with protected member variables. I'm struggling to see how I can access the member variable values outside the…
user275074
16
votes
2 answers

Why does changing the type lead to different usage of members?

So I was testing with some code snippets to wrap my head around the concept of inheritance, when I came across this - for me - strange phenomenon. So first I was testing this simple code: public class Main{ public static void main(String[] args)…
moffeltje
  • 4,521
  • 4
  • 33
  • 57
16
votes
1 answer

Public fields for Java compatibility

I found recent interest in Kotlin as a language, because the platform we develop for is Java 6 based and hence lacks any syntactic sugar the recent years brought to Java. There's but one thing that makes it impossible to use Kotlin over Java in…
John Smith
  • 752
  • 9
  • 35
16
votes
1 answer

Decltype of member functions

class A { int f(int x, int j) { return 2;} decltype(f)* p; }; Gives me the error: error: decltype cannot resolve address of overloaded function I can't understand why that error is even speaking of overloaded functions. Similarly I thought…
Silversonic
  • 1,289
  • 2
  • 11
  • 26
16
votes
2 answers

C++11 member variable of reference type, different behaviour after vector push_back

I was using somebody else's class which was acting odd when I pushed it into a vector. It involves a member variable which is a reference to another member variable. Here is the smallest self-contained example: #include #include…
badger5000
  • 650
  • 7
  • 17
16
votes
5 answers

Why do I get "warning: missing initializer for member"? [-Wmissing-field-initializers]?

Why am I getting a warning about initialization in one case, but not the other? The code is in a C++ source file, and I am using GCC 4.7 with -std=c++11. struct sigaction old_handler, new_handler; The above doesn't produce any warnings with -Wall…
jww
  • 97,681
  • 90
  • 411
  • 885
16
votes
4 answers

Storing a method as a member variable of a class

I have this as one of my members of the class 'KeyEvent': private delegate void eventmethod(); And the constructor: public KeyEvent(eventmethod D) { D(); } What I want to do is instead of calling D() there, I want to store that method (D) as…
Xenoprimate
  • 7,691
  • 15
  • 58
  • 95
15
votes
2 answers

MDX Calculated member filter by dimension attribute

I want to create a calculated member and filter it by dimension. This is WORKING example: ( [Policy].[Policy Status].&[Void], [Policy].[Tran Type].&[Renewal], [Measures].[FK Policy Distinct Count] ) But if I want to filter it like…
ilija veselica
  • 9,414
  • 39
  • 93
  • 147
15
votes
4 answers

c++ alternative member definition

In C++ you can define members the following way: struct test { using memberType = int(int); /*virtual*/ memberType member; }; int test::member(int x) { return x; } With C++14 is there any way to define the member inside the class…
Gaetano
  • 1,090
  • 1
  • 9
  • 25
15
votes
3 answers

C++ template static member instantiation

#include #include template class A { static std::map data; public: A() { std::cout << data.size() << std::endl; data[3] = 4; } }; template std::map A::data; //std::map
mrs
  • 151
  • 1
  • 3
14
votes
7 answers

Does an element exists in a list of lists?

I want to find if a given element exists in a list of lists. I am only getting true if the element exists somewhere is the first list of lists. Any advice? memberlist(X,[[X|T1]|T2]). memberlist(X,[[H|T1]|T2]) :- memberlist(X,[T1|T2]).
Alator
  • 497
  • 6
  • 23