Search Results

Search found 3208 results on 129 pages for 'members'.

Page 3/129 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • C++ struct, public data members and inheritance

    - by Marius
    Is it ok to have public data members in a C++ class/struct in certain particular situations? How would that go along with inheritance? I've read opinions on the matter, some stated already here http://stackoverflow.com/questions/952907/practices-on-when-to-implement-accessors-on-private-member-variables-rather-than http://stackoverflow.com/questions/670958/accessors-vs-public-members or in books/articles (Stroustrup, Meyers) but I'm still a little bit in the shade. I have some configuration blocks that I read from a file (integers, bools, floats) and I need to place them into a structure for later use. I don't want to expose these externally just use them inside another class (I actually do want to pass these config parameters to another class but don't want to expose them through a public API). The fact is that I have many such config parameters (15 or so) and writing getters and setters seems an unnecessary overhead. Also I have more than one configuration block and these are sharing some of the parameters. Making a struct with all the data members public and then subclassing does not feel right. What's the best way to tackle that situation? Does making a big struct to cover all parameters provide an acceptable compromise (I would have to leave some of these set to their default values for blocks that do not use them)?

    Read the article

  • Protected Members of Other Instances in Scala

    - by Masterofpsi
    I just ran into a difficulty while learning Scala. I have an inheritance hierarchy that is essentially equivalent to this: class A { protected def myMethod() = println("myMethod() from A") } class B extends A { def invokeMyMethod(a: A) = a.myMethod() } But trying to compile this sample, I get the error "test.scala:7: error: method myMethod cannot be accessed in A". Coming from Java, my understanding is that protected members should be accessible at any point from a derived class, and nowhere have I seen anything that tells me that protected members in Scala are limited by instance. Does anyone have an explanation for this?

    Read the article

  • Get a list of members of a WinNT group (C#)

    - by Keith Moore
    There are a couple of questions similar to this on stack overflow but not quite the same. I want to open, or create, a local group on a win xp computer and add members to it, domain, local and well known accounts. I also want to check whether a user is already a member so that I don't add the same account twice, and presumably get an exception. So far I started using the DirectoryEntry object with the WinNT:// provider. This is going ok but I'm stuck on how to get a list of members of a group? Anyone know how to do this? Or provide a better solution than using DirectoryEntry?

    Read the article

  • System.WIndows.Application static members are thread safe?

    - by Lirik
    The Application static members are supposed to be thread safe: The public static (Shared in Visual Basic) members of this type are thread safe. In addition, the FindResource and TryFindResource methods and the Properties and Resources properties are thread safe.1 How much can we trust that statement in a multithreaded environment when calling static member methods of System.Windows.Application? Update: It's all in reference to this question: http://stackoverflow.com/questions/2463822/threading-errors-with-application-loadcomponent-key-already-exists/2463866#2463866 I never thought I'd see a real bug in the library, but this must be the day for me... that question seems to show a genuine bug. Usually it's "user error," but this doesn't seem to be the case.

    Read the article

  • Vim + OmniCppComplete: Completing on Class Members which are STL containers

    - by Robert S. Barnes
    Completion on class members which are STL containers is failing. Completion on local objects which are STL containers works fine. For example, given the following files: // foo.h #include <string> class foo { public: void set_str(const std::string &); std::string get_str_reverse( void ); private: std::string str; }; // foo.cpp #include "foo.h" using std::string; string foo::get_str_reverse ( void ) { string temp; temp.assign(str); reverse(temp.begin(), temp.end()); return temp; } /* ----- end of method foo::get_str ----- */ void foo::set_str ( const string &s ) { str.assign(s); } /* ----- end of method foo::set_str ----- */ I've generated the tags for these two files using: ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q . When I type temp. in the cpp I get a list of string member functions as expected. But if I type str. omnicppcomplete spits out "Pattern Not Found". I've noticed that the temp. completion only works if I have the using std::string; declaration. How do I get completion to work on my class members which are STL containers? Edit I found that completion on members which are STL containers works if I make the follow modifications to the header: // foo.h #include <string> using std::string; class foo { public: void set_str(const string &); string get_str_reverse( void ); private: string str; }; Basically, if I add using std::string; and then remove the std:: name space qualifier from the string str; member and regenerate the tags file then OmniCppComplete is able to do completion on str.. It doesn't seem to matter whether or not I have let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] set in the .vimrc. The problem is that putting using declarations in header files seems like a big no-no, so I'm back to square one.

    Read the article

  • What are pointers to class members used for?

    - by srikfreak
    I have read about pointers to class members, but I have never seen them being used in any practical applications. Can someone explain what are the use cases of such pointers? Is it really necessary to have such pointers? Eg. class abc { public: int a; abc(int val) { a = val; } }; int main { int abc::*data; abc obj(5); data = &abc::a; cout << "Value of a is " << obj.*data << endl; return 0; } In the above eg. why is the value of 'a' accessed in this manner? What is the advantage of using pointers to class members?

    Read the article

  • Does changing the order of class private data members breaks ABI

    - by Dmitry Yudakov
    I have a class with number of private data members (some of them static), accessed by virtual and non-virtual member functions. There's no inline functions and no friend classes. class A { int number; string str; static const int static_const_number; public: // got virtual and non-virtual functions, working with these memebers virtual void func1(); void func2(); // no inline functions or friends }; Does changing the order of private data members breaks ABI in this case? class A { string str; static const int static_const_number; int number; // <-- integer member moved here ... };

    Read the article

  • Custom Attributes on Class Members

    - by ccook
    I am using a Custom Attribute to define how a class's members are mapped to properties for posting as a form post (Payment Gateway). I have the custom attribute working just fine, and am able to get the attribute by "name", but would like to get the attribute by the member itself. For example: getFieldName("name"); vs getFieldName(obj.Name); The plan is to write a method to serialize the class with members into a postable string. Here's the test code I have at this point, where ret is a string and PropertyMapping is the custom attribute: foreach (MemberInfo i in (typeof(CustomClass)).GetMember("Name")) { foreach (object at in i.GetCustomAttributes(true)) { PropertyMapping map = at as PropertyMapping; if (map != null) { ret += map.FieldName; } } } Thanks in advance!

    Read the article

  • How to apply patterns when not all team members can follow them

    - by michael moore
    We're going to start a new huge project and while it's in the process of architecting the system, I have certain doubts whether I can apply patterns and be sure they won't be violated by team members. The problem is, not all team members have enough skills to develop asp.net apps let's say using MVP pattern. So maybe this question is addressed to Team leads, or experienced devs. Did you dealt with this kind of situation, and if so what was your solution. I was thinking to create the core by myself, and let 'em start building upon that core, however I'm not sure it will work out.

    Read the article

  • Using a class with const data members in a vector

    - by Max
    Given a class like this: class Foo { const int a; }; Is it possible to put that class in a vector? When I try, my compiler tells me it can't use the default assignment operator. I try to write my own, but googling around tells me that it's impossible to write an assignment operator for a class with const data members. One post I found said that "if you made [the data member] const that means you don't want assignment to happen in the first place." This makes sense. I've written a class with const data members, and I never intended on using assignment on it, but apparently I need assignment to put it in a vector. Is there a way around this that still preserves const-correctness?

    Read the article

  • Are volatile data members trivially copyable?

    - by Lightness Races in Orbit
    Whilst writing this answer I realised that I'm not as confident about my conclusions as I usually would ensure before hitting Post Your Answer. I can find a couple of reasonably convincing citations for the argument that the trivial-copyability of volatile data members is either implementation defined or flat-out false: https://groups.google.com/forum/?fromgroups=#!topic/comp.std.c++/5cWxmw71ktI http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48118 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3159.html#496 But I haven't been able to back this up in the standard1 itself. Particularly "worrying" is that there's no sign of the proposed wording change from that n3159 issues list in the actual standard's final wording. So, what gives? Are volatile data members trivially copyable, or not? 1   C++11

    Read the article

  • Comparing Java enum members: == or equals() ?

    - by Bears will eat you
    I know that Java enums are compiled to classes with private constructors and a bunch of public static members. When comparing two members of a given enum, I've always used .equals(), e.g. public useEnums(SomeEnum a) { if(a.equals(SomeEnum.SOME_ENUM_VALUE)) { ... } ... } However, I just came across come code that uses the equals operator == instead: public useEnums2(SomeEnum a) { if(a == SomeEnum.SOME_ENUM_VALUE) { ... } ... } I've been programming in Java for 5+ years, and I thought I understood difference between the two - but I'm still scratching my head at which one is more correct. Which operator is the one I should be using?

    Read the article

  • Visual Studio IntelliSense - IHideObjectMembers trick doesn't work. What am I missing?

    - by stakx
    The IHideObjectMembers trick can be used e.g. in fluent interface implementations to hide System.Object members from IntelliSense. (If you don't know this trick, you can read up on it via the above link; I'm just repeating the interface's usual declaration here:) using System; using System.ComponentModel; [EditorBrowsable(EditorBrowsableState.Never)] public interface IHideObjectMembers { [EditorBrowsable(EditorBrowsableState.Never)] Type GetType(); [EditorBrowsable(EditorBrowsableState.Never)] int GetHashCode(); [EditorBrowsable(EditorBrowsableState.Never)] string ToString(); [EditorBrowsable(EditorBrowsableState.Never)] bool Equals(object obj); } I'm now supposed to be able to hide System.Object members on another type as follows: public class SomeClass : IHideObjectMembers { ... } or: public class ISomeInterface : IHideObjectMembers { ... } I tried this in both VS 2008 Express and VS 2008 Standard. However, no members are hidden from IntelliSense at all. I have used the EditorBrowsableAttribute in different projects and it always worked well; however, it doesn't work in this particular scenario. If things had worked as expected, I would only have seen the SomeMethodTwo method. Am I missing something?

    Read the article

  • ADSIEdit freezes gettings properties of a group with hundred of thousands members

    - by ixe013
    Doing performance testing on an AD-LDS (Server 2008 R2 64 bits), we created a milion user in a single OU. We also created a single group object and made those milion users member of that group. When we try to list the milion of users ADSIEdit times out with an error message saying it cannot display that many users. Fine. But if we open the properties for the group, ADSIEdit freezes, eating up all available memory and CPU trashing (nearly 60M page faults in under an hour). AD-LDS (running on another computer) is barely hitting the 1% CPU mark, servicing other ldap requests as if nothing were. We can throw more memory at the problem, but more users will have to be managed one day and we will be back at square one. Is there a way to set a limit in ADSIEdit so that it will not hang the computer when retreving a very large multi-value object ?

    Read the article

  • Listing group members using ldapsearch

    - by colemanm
    Our corporate LDAP directory is housed on a Snow Leopard Server Open Directory setup. I'm trying to use the ldapsearch tool to export an .ldif file to import into another external LDAP server to authenticate with externally; basically trying to be able to use the same credentials internally and externally. I've got ldapsearch working and giving me the contents and attributes of everything in the "Users" OU, and even filtering down to only the attributes I need: ldapsearch -xLLL -H ldap://server.domain.net / -b "cn=users,dc=server,dc=domain,dc=net" objectClass / uid uidNumber cn userPassword > directorycontents.ldif That gives me a list of users and properties that I can import to my remote OpenLDAP server. dn: uid=username1,cn=users,dc=server,dc=domain,dc=net objectClass: inetOrgPerson objectClass: posixAccount objectClass: organizationalPerson uidNumber: 1000 uid: username1 userPassword:: (hashedpassword) cn: username1 However, when I try the same query on an OD "group" instead of a "container," the results are something like this: dn: cn=groupname,cn=groups,dc=server,dc=domain,dc=net objectClass: posixGroup objectClass: apple-group objectClass: extensibleObject objectClass: top gidNumber: 1032 cn: groupname memberUid: username1 memberUid: username2 memberUid: username3 What I really want is a list of users from the top example filtered based on their group memberships, but it looks like membership is set from the Group side, rather than the user account side. There must be a way to filter this down and only export what I need, right?

    Read the article

  • Listing group members using ldapsearch

    - by colemanm
    Our corporate LDAP directory is housed on a Snow Leopard Server Open Directory setup. I'm trying to use the ldapsearch tool to export an .ldif file to import into another external LDAP server to authenticate with externally; basically trying to be able to use the same credentials internally and externally. I've got ldapsearch working and giving me the contents and attributes of everything in the "Users" OU, and even filtering down to only the attributes I need: ldapsearch -xLLL -H ldap://server.domain.net / -b "cn=users,dc=server,dc=domain,dc=net" objectClass / uid uidNumber cn userPassword > directorycontents.ldif That gives me a list of users and properties that I can import to my remote OpenLDAP server. dn: uid=username1,cn=users,dc=server,dc=domain,dc=net objectClass: inetOrgPerson objectClass: posixAccount objectClass: organizationalPerson uidNumber: 1000 uid: username1 userPassword:: (hashedpassword) cn: username1 However, when I try the same query on an OD "group" instead of a "container," the results are something like this: dn: cn=groupname,cn=groups,dc=server,dc=domain,dc=net objectClass: posixGroup objectClass: apple-group objectClass: extensibleObject objectClass: top gidNumber: 1032 cn: groupname memberUid: username1 memberUid: username2 memberUid: username3 What I really want is a list of users from the top example filtered based on their group memberships, but it looks like membership is set from the Group side, rather than the user account side. There must be a way to filter this down and only export what I need, right?

    Read the article

  • Time until Members added to Group Policy is Replicated

    - by Kyle Brandt
    If I have a group policy, and add a group/user/machine etc to that group policy, how long is it until all domain controllers have that change in effect? This is a Windows 2003 Domain set up with controllers at different geographic locations (Each with a different L3 network). I realize it probably depends, but how do I figure out how long it generally takes for my given setup? Also, is there an event I can check to see if it has a reached a particular domain controller?

    Read the article

  • Samba does not reload user group members

    - by xato
    I am running a simple samba server setup where users connect to a share which contains folders for specific user groups. The folders are chmod 2770, so only users which are in the correct group can read/write in them. The problem is that if I change group memberships (i.e. remove user from group / add user to group; changes are in sync between clients and server!) samba does not automatically reload the group memberships for the user, so they can still write to groups that they are no longer a member of etc. I either have to reconnect to the share or to restart samba to apply the changes. Is there any way to prevent group caching and/or enable group membership reload in samba? My smb.conf: https://gist.github.com/anonymous/ca7c10a3b3e2168d7a03

    Read the article

  • Sandbox on a linux server for group members

    - by mgualt
    I am a member of a large group (academic department) using a central GNU/Linux server. I would like to be able to install web apps like instiki, run version control repositories, and serve content over the web. But the admins won't permit this due to security concerns. Is there a way for them to sandbox me, protecting their servers in case I am hacked? What is the standard solution for a problem like this?

    Read the article

  • boost::serialization with mutable members

    - by redmoskito
    Using boost::serialization, what's the "best" way to serialize an object that contains cached, derived values in mutable members, such that cached members aren't serialized, but on deserialization, they are initialized the their appropriate default. A definition of "best" follows later, but first an example: class Example { public: Example(float n) : num(n), sqrt_num(-1.0) {} float get_num() const { return num; } // compute and cache sqrt on first read float get_sqrt() const { if(sqrt_num < 0) sqrt_num = sqrt(num); return sqrt_num; } template <class Archive> void serialize(Archive& ar, unsigned int version) { ... } private: float num; mutable float sqrt_num; }; On serialization, only the "num" member should be saved. On deserialization, the sqrt_num member must be initialized to its sentinel value indicating it needs to be computed. What is the most elegant way to implement this? In my mind, an elegant solution would avoid splitting serialize() into separate save() and load() methods (which introduces maintenance problems). One possible implementation of serialize: template <class Archive> void serialize(Archive& ar, unsigned int version) { ar & num; sqrt_num = -1.0; } This handles the deserialization case, but in the serialization case, the cached value is killed and must be recomputed. Also, I've never seen an example of boost::serialize that explicitly sets members inside of serialize(), so I wonder if this is generally not recommended. Some might suggest that the default constructor handles this, for example: int main() { Example e; { std::ifstream ifs("filename"); boost::archive::text_iarchive ia(ifs); ia >> e; } cout << e.get_sqrt() << endl; return 0; } which works in this case, but I think fails if the object receiving the deserialized data has already been initialized, as in the example below: int main() { Example ex1(4); Example ex2(9); cout << ex1.get_sqrt() << endl; // outputs 2; cout << ex2.get_sqrt() << endl; // outputs 3; // the following two blocks should implement ex2 = ex1; // save ex1 to archive { std::ofstream ofs("filename"); boost::archive::text_oarchive oa(ofs); oa << ex1; } // read it back into ex2 { std::ifstream ifs("filename"); boost::archive::text_iarchive ia(ifs); ia >> ex2; } // these should be equal now, but aren't, // since Example::serialize() doesn't modify num_sqrt cout << ex1.get_sqrt() << endl; // outputs 2; cout << ex2.get_sqrt() << endl; // outputs 3; return 0; } I'm sure this issue has come up with others, but I have struggled to find any documentation on this particular scenario. Thanks!

    Read the article

  • Accessing type members outside the class in Scala

    - by Pekka Mattila
    Hi, I am trying to understand type members in Scala. I wrote a simple example that tries to explain my question. First, I created two classes for types: class BaseclassForTypes class OwnType extends BaseclassForTypes Then, I defined an abstract type member in trait and then defined the type member in a concerete class: trait ScalaTypesTest { type T <: BaseclassForTypes def returnType: T } class ScalaTypesTestImpl extends ScalaTypesTest { type T = OwnType override def returnType: T = { new T } } Then, I want to access the type member (yes, the type is not needed here, but this explains my question). Both examples work. Solution 1. Declaring the type, but the problem here is that it does not use the type member and the type information is duplicated (caller and callee). val typeTest = new ScalaTypesTestImpl val typeObject:OwnType = typeTest.returnType // declare the type second time here true must beTrue Solution 2. Initializing the class and using the type through the object. I don't like this, since the class needs to be initialized val typeTest = new ScalaTypesTestImpl val typeObject:typeTest.T = typeTest.returnType // through an instance true must beTrue So, is there a better way of doing this or are type members meant to be used only with the internal implementation of a class?

    Read the article

  • C++ classes with members referencing each other

    - by Saad Imran.
    I'm trying to write 2 classes with members that reference each other. I'm not sure if I'm doing something wrong or it's just not possible. Can anyone help me out here... Source.cpp #include "Headers.h" using namespace std; void main() { Network* network = new Network(); system("pause"); return; } Headers.h #ifndef Headers_h #define Headers_h #include <iostream> #include <vector> #include "Network.h" #include "Router.h" #endif Network.h #include "Headers.h" class Network { protected: vector<Router> Routers; }; Router.h #include "Headers.h" class Router { protected: Network* network; public: }; The errors I'm getting are: error C2143: syntax error : missing ';' before '<' error C2238: unexpected token(s) preceding ';' error C4430: missing type specifier - int assumed. I'm pretty sure I'm not missing any semicolons or stuff like that. The program works find if I take out one of the members. I tried finding similar questions and the solution was to use pointers, but that's what I'm doing and it does't seem to be working!

    Read the article

  • OmniCppComplete: Completing on Class Members which are STL containers

    - by Robert S. Barnes
    Completion on class members which are STL containers is failing. Completion on local objects which are STL containers works fine. For example, given the following files: // foo.h #include <string> class foo { public: void set_str(const std::string &); std::string get_str_reverse( void ); private: std::string str; }; // foo.cpp #include "foo.h" using std::string; string foo::get_str_reverse ( void ) { string temp; temp.assign(str); reverse(temp.begin(), temp.end()); return temp; } /* ----- end of method foo::get_str ----- */ void foo::set_str ( const string &s ) { str.assign(s); } /* ----- end of method foo::set_str ----- */ I've generated the tags for these two files using: ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q . When I type temp. in the cpp I get a list of string member functions as expected. But if I type str. omnicppcomplete spits out "Pattern Not Found". I've noticed that the temp. completion only works if I have the using std::string; declaration. How do I get completion to work on my class members which are STL containers?

    Read the article

  • Properly obsoleting old members in an XML Serializable class in C# VB .NET

    - by George
    Hi! Some time ago I defined a class that was serialized using XML. That class contained a serializable propertyA of integer type. Now I have extended and updated this class, whereby a new propertyB was added, whose type is another class that also has several serializable properties. The new propertyB is now supposed to play the role of propertyA, that is since type of propertyB is another class, one of its members would contain the value that previously propertyA contained, thus making peroptyA obsolete. What I am trying to figure out is how do I make sure that when I desireliaze the OLD version of this class (without propertyB in it), I make sure that the desreializer would take the value of propertyA from the old calss and set it as a value of one of the members of propertyB in a new class? Private WithEvents _Position As Position = New Position(Alignment.MiddleMiddle, 0, True, 0, True) Public Property Position() As Position 'NEW composite property that holds the value of the obsolted property, i.e. Alignment Get Return _Position End Get Set(ByVal value As Position) _Position = value End Set End Property Private _Alignment As Alignment = Alignment.MiddleMiddle <Xml.Serialization.XmlIgnore(), Obsolete("Use Position property instead.")> _ Public Property Alignment() As Alignment'The old, obsoleted property that I guess must be left for compliance with deserializing the old version of this class Get Return _Alignment End Get Set(ByVal value As Alignment) _Alignment = value End Set End Property Can you help me, please?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >