Search Results

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

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

  • Sorting List which has object that contains two string members that contains numbers

    - by Lemo
    I want to know the best solution for this my case here is that i am taking values from Excel sheet and pushing them to database field, sometimes that field might contain some strings (thats why I cant make my object members int / double) In my class below size is the variable responsible for showing size of files in bytes public class dataNameValue { public string Name { get; set; } public string Count { get; set; } public string Size { get; set; } } I wanted to sort the list by file Size something like List mylist = new List(); mylist = mylist.OrderByDescending(i = i.Size).ToList(); The problem is that if i sorted it without converting it to "int/double" first -- its not giving right results

    Read the article

  • Cache for everybody except staff members.

    - by Oli
    I have a django site where I want to stick an "admin bar" along the top of every non-admin page for staff members. It would contain useful things like page editing tools, etc. The problem comes from me using the @cache_page decorator on lots of pages. If a normal user hits a page, the cached version comes up without the admin bar (even for admin users) and if an admin hits the page first, normal users see the admin bar. I could tediously step through the templates, adding regional cache blocks but there are a lot of templates, and life is altogether too short. Ideally, there would be a way of telling the caching to ignore cache get/set requests from admin users... But I don't know how to best implement that. How would you tackle this problem?

    Read the article

  • SQL finding members who are not friends of another member

    - by thedirktastik
    I'm struggling to find a query which will return members who aren't friends of a certain member. Here is the layout of my tables: member_login: MemberID, email, password member_info: memberID, first_name, last_name member_friends: friendID, req_member, req_date, app_member, app_date, date_deactivated I tried to use NOT IN to run a query that would return the opposite of friends but nothing I try seems to be working. Here's what I thought would work: SELECT Mi.First_Name, Mi.Last_Name FROM Member_Info Mi WHERE Mi.Memberid NOT IN( SELECT Mi.Memberid, Mi.First_Name, Mi.Last_Name FROM Member_Info Mi, Member_Login Ml, Member_Friends Mf WHERE Mi.Memberid = Ml.Memberid AND (Mi.Memberid = Mf.Req_Member AND Mf.App_Member = 1 OR Mi.Memberid = Mf.App_Member AND Mf.Req_Member =1) AND Ml.Date_Deactivated <= 0 AND Mf.App_Date > 0 ); Any ideas?

    Read the article

  • Where to put constant strings in C++: static class members or anonymous namespaces

    - by stone
    I need to define some constant strings that will be used only by one class. It looks like I have three options: Embed the strings directly into locations where they are used. Define them as private static constant members of the class: //A.h class A { private: static const std::string f1; static const std::string f2; static const std::string f3; }; //A.cpp const std::string f1 = "filename1"; const std::string f2 = "filename2"; const std::string f3 = "filename3"; //strings are used in this file Define them in an anonymous namespace in the cpp file: //A.cpp namespace { const std::string f1 = "filename1"; const std::string f2 = "filename2"; const std::string f3 = "filename3"; } //strings are used in this file Given these options, which one would you recommend and why? Thanks.

    Read the article

  • Class members allocation on heap/stack? C++

    - by simplebutperfect
    If a class is declared as follows: class MyClass { char * MyMember; MyClass() { MyMember = new char[250]; } ~MyClass() { delete[] MyMember; } }; And it could be done like this: class MyClass { char MyMember[250]; }; How does a class gets allocated on heap, like if i do MyClass * Mine = new MyClass(); Does the allocated memory also allocates the 250 bytes in the second example along with the class instantiation? And will the member be valid for the whole lifetime of MyClass object? As for the first example, is it practical to allocate class members on heap?

    Read the article

  • Implementing an interface with interface members

    - by jstark
    What is the proper way to implement an interface that has its own interface members? (am I saying that correctly?) Here's what I mean: public Interface IFoo { string Forty { get; set; } string Two { get; set; } } public Interface IBar { // other stuff... IFoo Answer { get; set; } } public class Foo : IFoo { public string Forty { get; set; } public string Two { get; set; } } public class Bar : IBar { // other stuff public Foo Answer { get; set; } //why doesnt' this work? } I've gotten around my problem using explicit interface implementation, but I'm wondering if there is a better way?

    Read the article

  • problems with overloaded function members C++

    - by Dr Deo
    I have declared a class as class DCFrameListener : public FrameListener, public OIS::MouseListener, public OIS::KeyListener { bool keyPressed(const OIS::KeyEvent & kEvt); bool keyReleased(const OIS::KeyEvent &kEvt); //*******some code missing************************ }; But if i try defining the members like this bool DCFrameListener::keyPressed(const OIS::KeyEvent kEvt) { return true; } The compiler refuses with this error error C2511: 'bool DCFrameListener::keyPressed(const OIS::KeyEvent)' : overloaded member function not found in 'DCFrameListener' see declaration of 'DCFrameListener' Why is this happening, yet i declared the member keyPressed(const OIS::KeyEvent) in my function declaration. any help will be appreciated. Thanks

    Read the article

  • Explicit initialization of struct/class members

    - by Zephon
    struct some_struct{ int a; }; some_struct n = {}; n.a will be 0 after this; I know this braces form of initialization is inherited from C and is supported for compatibility with C programs, but this only compiles with C++, not with the C compiler. I'm using Visual C++ 2005. In C this type of initialization struct some_struct n = {0}; is correct and will zero-initialize all members of a structure. Is the empty pair of braces form of initialization standard? I first saw this form of initialization in a WinAPI tutorial from msdn.

    Read the article

  • objective-c releasing uninitialized class members in dealloc method

    - by Dude Man
    Regarding over-releasing. Say I have a instance variable defined in Test.h NSString *mystring; In my implementation Test.m I do not initialize the variable mystring anywhere. But I release it in dealloc: -(void)dealloc { [mystring release]; } Is this now over-released? I've been doing the following in dealloc to avoid any issues, however, is this really necessary? -(void)dealloc { if (mystring) [mystring release]; } It seems that [nil release] shouldn't do anything, can someone verify this with class members?

    Read the article

  • C++ Constructor Initializer List - using member functions of initialized members

    - by Andy
    I've run into the following a few times with initializer lists and I've never been able to explain it well. Can anyone explain why exactly the following fails (I don't have a compiler to catch typos, so bear with me): class Foo { public: Foo( int i ) : m_i( i ) {} //works with no problem int getInt() {return m_i;} ~Foo {} private: int m_i; }; class Bar { public: Bar() : m_foo( 5 ), //this is ok m_myInt( m_foo.getInt() ) //runtime error, seg 11 {} ~Bar() {} private: Foo m_foo; int m_myInt; }; When trying to call member functions of members initialized higher up the initializer list, I get seg faults. I seem to recall this is a known problem (or perhaps somehow by design) but I've never seen it well described. The attached example is contrived with plain old data types, but substitute the Bar::m_myInt with another object lacking a default (empty) constructor and the issue is more real. Can anyone enlighten me? Thanks!

    Read the article

  • Prevent mapping all public members of a class in Fluent NHibernate

    - by alimbada
    I have a class generated from a WSDL that has a bunch of public properties and a public event. I'm extending this class with my own and adding some properties to it. All of my own properties are declared virtual, but the base class properties are not virtual. I'm using Fluent NHibernate's ClassMap to map only the properties from my extended class. How do I prevent (Fluent)NHibernate from trying to persist all the base class's public members? At the moment, I get the following exception when creating the ISessionFactory: NHibernate.InvalidProxyTypeException: The following types may not be used as proxies: Type: method get_<BaseClassProperty should be 'public/protected virtual' or 'protected internal virtual' Type: method set_<BaseClassProperty should be 'public/protected virtual' or 'protected internal virtual' ... Type: method add_<BaseClassEvent should be 'public/protected virtual' or 'protected internal virtual' Type: method remove_<BaseClassEvent should be 'public/protected virtual' or 'protected internal virtual'

    Read the article

  • Class Members Over Exports

    - by VirusEcks
    When Using DLLs or Code-injecting to be Specific this is an example class only intended for explaining class test { int newint1; char newchararray[512]; void (*newfunction1)( int newarg1 ); int newfunction2( bool newarg1, char newarg2 ) { return newint1; } } mynewclass1; that covers most common elements that's included in classes now when exporting this function to another DLL or application and missed an element of those, either data member or function member, private or public what happens or changed their order ? and if each function is assigned it's value when Code-Injecting like mynewclass1.newfunction1 = (void *)(newexportedfunction); what's the happens in this case, if members of the class are pointers that are assigned after class construction and then missed one member or changed their order ?

    Read the article

  • how to allocate memory for struct itself, and its members

    - by Jack
    I have this struct: struct foo { char *a; char *b; char *c; char *d; }; it's possible allocate space for struct itself and its members instead of e.g, struct foo f; f.a = malloc(); f.b = malloc(); f.c = malloc(); f.d = malloc(); strcpy(f.a, "a"); strcpy(f.b, "b"); //.. something like this(of couse that it doesn't works): struct foo f = malloc(sizeof(struct f)); strpcy(f.a, "a"); //etc

    Read the article

  • C++ - defining static const integer members in class definition

    - by HighCommander4
    My understanding is that C++ allows static const members to be defined inside a class so long as it's an integer type. Why, then, does the following code give me a linker error? #include <algorithm> #include <iostream> class test { public: static const int N = 10; }; int main() { std::cout << test::N << "\n"; std::min(9, test::N); } The error I get is: test.cpp:(.text+0x130): undefined reference to `test::N' collect2: ld returned 1 exit status Interestingly, if I comment out the call to std::min, the code compiles and links just fine (even though test::N is also referenced on the previous line). Any idea as to what's going on? My compiler is gcc 4.4 on Linux.

    Read the article

  • Static initialization of a struct with class members

    - by JS Bangs
    I have a struct that's defined with a large number of vanilla char* pointers, but also an object member. When I try to statically initialize such a struct, I get a compiler error. typedef struct { const char* pszA; // ... snip ... const char* pszZ; SomeObject obj; } example_struct; // I only want to assign the first few members, the rest should be default example_struct ex = { "a", "b" }; SomeObject has a public default constructor with no arguments, so I didn't think this would be a problem. But when I try to compile this (using VS), I get the following error: error C2248: 'SomeObject::SomeObject' : cannot access private member declared in class 'SomeObject' Any idea why?

    Read the article

  • C++ performance when accessing class members

    - by Dr. Acula
    I'm writing something performance-critical and wanted to know if it could make a difference if I use: int test( int a, int b, int c ) { // Do millions of calculations with a, b, c } or class myStorage { public: int a, b, c; }; int test( myStorage values ) { // Do millions of calculations with values.a, values.b, values.c } Does this basically result in similar code? Is there an extra overhead of accessing the class members? I'm sure that this is clear to an expert in C++ so I won't try and write an unrealistic benchmark for it right now

    Read the article

  • Python: Access members of a set

    - by emu
    Say I have a set myset of custom objects that may be equal although their references are different (a == b and a is not b). Now if I add(a) to the set, Python correctly assumes that a in myset and b in myset even though there is only len(myset) == 1 object in the set. That is clear. But is it now possible to extract the value of a somehow out from the set, using b only? Suppose that the objects are mutable and I want to change them both, having forgotten the direct reference to a. Put differently, I am looking for the myset[b] operation, which would return exactly the member a of the set. It seems to me that the type set cannot do this (faster than iterating through all its members). If so, is there at least an effective work-around?

    Read the article

  • Performance when accessing class members

    - by Dr. Acula
    I'm writing something performance-critical and wanted to know if it could make a difference if I use: int test( int a, int b, int c ) { // Do millions of calculations with a, b, c } or class myStorage { public: int a, b, c; }; int test( myStorage values ) { // Do millions of calculations with values.a, values.b, values.c } Does this basically result in similar code? Is there an extra overhead of accessing the class members? I'm sure that this is clear to an expert in C++ so I won't try and write an unrealistic benchmark for it right now

    Read the article

  • Are static members inherited? (C++)

    - by Keand64
    When static members are inherited, are they static for the entire heirarchy, or just that class, ie: class SomeClass { public: SomeClass(){total++;} static int total; }; class SomeDerivedClass: public SomeClass { public: SomeDerivedClass(){total++;} }; int main() { SomeClass A; SomeClass B; SomeDerivedClass C; return 0; } would total be 3 in all three instances, or would it be 2 for SomeClass and 1 for SomeDerivedClass?

    Read the article

  • Access cost of dynamically created objects with dynamically allocated members

    - by user343547
    I'm building an application which will have dynamic allocated objects of type A each with a dynamically allocated member (v) similar to the below class class A { int a; int b; int* v; }; where: The memory for v will be allocated in the constructor. v will be allocated once when an object of type A is created and will never need to be resized. The size of v will vary across all instances of A. The application will potentially have a huge number of such objects and mostly need to stream a large number of these objects through the CPU but only need to perform very simple computations on the members variables. Could having v dynamically allocated could mean that an instance of A and its member v are not located together in memory? What tools and techniques can be used to test if this fragmentation is a performance bottleneck? If such fragmentation is a performance issue, are there any techniques that could allow A and v to allocated in a continuous region of memory? Or are there any techniques to aid memory access such as pre-fetching scheme? for example get an object of type A operate on the other member variables whilst pre-fetching v. If the size of v or an acceptable maximum size could be known at compile time would replacing v with a fixed sized array like int v[max_length] lead to better performance? The target platforms are standard desktop machines with x86/AMD64 processors, Windows or Linux OSes and compiled using either GCC or MSVC compilers.

    Read the article

  • Inheritance inside a template - public members become invisible?

    - by Juliano
    I'm trying to use inheritance among classes defined inside a class template (inner classes). However, the compiler (GCC) is refusing to give me access to public members in the base class. Example code: template <int D> struct Space { struct Plane { Plane(Space& b); virtual int& at(int y, int z) = 0; Space& space; /* <= this member is public */ }; struct PlaneX: public Plane { /* using Plane::space; */ PlaneX(Space& b, int x); int& at(int y, int z); const int cx; }; int& at(int x, int y, int z); }; template <int D> int& Space<D>::PlaneX::at(int y, int z) { return space.at(cx, y, z); /* <= but it fails here */ }; Space<4> sp4; The compiler says: file.cpp: In member function ‘int& Space::PlaneX::at(int, int)’: file.cpp:21: error: ‘space’ was not declared in this scope If using Plane::space; is added to the definition of class PlaneX, or if the base class member is accessed through the this pointer, or if class Space is changed to a non-template class, then the compiler is fine with it. I don't know if this is either some obscure restriction of C++, or a bug in GCC (GCC versions 4.4.1 and 4.4.3 tested). Does anyone have an idea?

    Read the article

  • Field Members vs Method Variables?

    - by Braveyard
    Recently I've been thinking about performance difference between class field members and method variables. What exactly I mean is in the example below : Lets say we have a DataContext object for Linq2SQL class DataLayer { ProductDataContext context = new ProductDataContext(); public IQueryable<Product> GetData() { return context.Where(t=>t.ProductId == 2); } } In the example above, context will be stored in heap and the GetData method variables will be removed from Stack after Method is executed. So lets examine the following example to make a distinction : class DataLayer { public IQueryable<Product> GetData() { ProductDataContext context = new ProductDataContext(); return context.Where(t=>t.ProductId == 2); } } (*1) So okay first thing we know is if we define ProductDataContext instance as a field, we can reach it everywhere in the class which means we don't have to create same object instance all the time. But lets say we are talking about Asp.NET and once the users press submit button the post data is sent to the server and the events are executed and the posted data stored in a database via the method above so it is probable that the same user can send different data after one another.If I know correctly after the page is executed, the finalizers come into play and clear things from memory (from heap) and that means we lose our instance variables from memory as well and after another post, DataContext should be created once again for the new page cycle. So it seems the only benefit of declaring it publicly to the whole class is the just number one text above. Or is there something other? Thanks in advance... (If I told something incorrect please fix me.. )

    Read the article

  • WCF REST Starter Kit not filling base class members on POST

    - by HJG
    I have a WCF REST Starter Kit service. The type handled by the service is a subclass of a base class. For POST requests, the base class members are not correctly populated. The class hierarchy looks like this: [DataContract] public class BaseTreeItem { [DataMember] public String Id { get; set; } [DataMember] public String Description { get; set; } } [DataContract] public class Discipline : BaseTreeItem { ... } The service definition looks like: [WebHelp(Comment = "Retrieve a Discipline")] [WebGet(UriTemplate = "discipline?id={id}")] [OperationContract] public Discipline getDiscipline(String id) { ... } [WebHelp(Comment = "Create/Update/Delete a Discipline")] [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "discipline")] public WCF_Result DisciplineMaintenance(Discipline discipline) { ... } Problem: While the GET works fine (returns the base class Id and Description), the POST does not populate Id and Description even though the XML contains the fields. Sample XML: <?xml version="1.0" encoding="utf-8"?> <Discipline xmlns="http://schemas.datacontract.org/2004/07/xxx.yyy.zzz"> <DeleteFlag>7</DeleteFlag> <Description>2</Description> <Id>5</Id> <DisciplineName>1</DisciplineName> <DisciplineOwnerId>4</DisciplineOwnerId> <DisciplineOwnerLoginName>3</DisciplineOwnerLoginName> </Discipline> Thanks for any assistance.

    Read the article

  • C++ private inheritance and static members/types

    - by WearyMonkey
    I am trying to stop a class from being able to convert its 'this' pointer into a pointer of one of its interfaces. I do this by using private inheritance via a middle proxy class. The problem is that I find private inheritance makes all public static members and types of the base class inaccessible to all classes under the inheriting class in the hierarchy. class Base { public: enum Enum { value }; }; class Middle : private Base { }; class Child : public Middle { public: void Method() { Base::Enum e = Base::value; // doesn't compile BAD! Base* base = this; // doesn't compile GOOD! } }; I've tried this in both VS2008 (the required version) and VS2010, neither work. Can anyone think of a workaround? Or a different approach to stopping the conversion? Also I am curios of the behavior, is it just a side effect of the compiler implementation, or is it by design? If by design, then why? I always thought of private inheritance to mean that nobody knows Middle inherits from Base. However, the exhibited behavior implies private inheritance means a lot more than that, in-fact Child has less access to Base than any namespace not in the class hierarchy!

    Read the article

  • Accessing derived class members with a base class pointer

    - by LRB
    I am making a simple console game in C++ I would like to know if I can access members from the 'entPlayer' class while using a pointer that is pointing to the base class ( 'Entity' ): class Entity { public: void setId(int id) { Id = id; } int getId() { return Id; } protected: int Id; }; class entPlayer : public Entity { string Name; public: entPlayer() { Name = ""; Id = 0; } void setName(string name) { Name = name; } string getName() { return Name; } }; Entity *createEntity(string Type) { Entity *Ent = NULL; if (Type == "player") { Ent = new entPlayer; } return Ent; } void main() { Entity *ply = createEntity("player"); ply->setName("Test"); ply->setId(1); cout << ply->getName() << endl; cout << ply->getId() << endl; delete ply; } How would I be able to call ply-setName etc? OR If it's not possible that way, what would be a better way?

    Read the article

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