Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Operator overloading in c (not c++) is it possible? -


this question arises need "convert" std::string char* form.

preferably maintain code possible , includes plenty of "=" initialization/assignment operators.

standard c operators exist basic data types (int, char, float, pointers to, etc...).

is possible overload assignment operator in c? suppose each data type it's own operator messing 1 wouldn't mess others.

anyhow, intrigued me can't find references on how c operators implemented.

cheers

well, examples in order

std::string a_string; a_string = "bla" 

or using standard c

char a_char_array[10]; strcpy(a_char_array,"bla"); 

or

char *a_char_pointer = "bla"; 

what i'm thinking wa replace these 3 use cases single 1 can (through #define) switch between using char* or std::string.

i guess cares performance vs coding speed has thought implications of using std::string instead of char*. of advantages of using stl offseted (is word!?) lower performance (you can't want right??).

as said, have large project , want see myself changes in using 1 method or other.

my post title purposely misleading didn't want become char* vs string battle, guess can't explain want without more details.

cheers

no, in c overloading of = not possible, simple reason: defined (almost) types.

you'd have distinguish between assignment , initialization. whereas initialization of arrays possible, assignment not. if strings compile time determined, easy:

char copy[] = { "abcd" }; // initialization, ok copy = "1234";            // assignment, error 

a trick overcome problem encapsulate string in struct

typedef struct mystring mystring; struct mystring { char a[24]; };  mystring = { "abcd" }; mystring b = a; mystring c = { 0 }; c = b; 

this right thing if care initialize variables indicated above.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -