declaration

Explain blank class functions in C++

女生的网名这么多〃 提交于 2019-12-11 08:48:19
问题 class forums : public master{ public: forums() : next(0),prev(0) {} } Please Explain what exactly does the functions next(0) and prev(0) are meant? What does seperation of function with a comma (,) indicates? what's the effect of empty braces {}, next to these functions? I am a beginner in C++, and trying to figure out what does this means, or intended use for these way of writing function? like is it specially meant for overriding? 回答1: Short answer That is a constructor with an empty body,

swift dictionary population issue: type 'AnyObject' does not conform to protocol 'NSCopying'

泄露秘密 提交于 2019-12-11 08:20:49
问题 I am trying to migrate the next code from Objetive-C to Swift: NSArray *voices = [AVSpeechSynthesisVoice speechVoices]; NSArray *languages = [voices valueForKey:@"language"]; NSLocale *currentLocale = [NSLocale autoupdatingCurrentLocale]; NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; for (NSString *code in languages) { dictionary[code] = [currentLocale displayNameForKey:NSLocaleIdentifier value:code]; } And I did the following: var voices:NSArray = AVSpeechSynthesisVoice

How to create ambient declarations for Twilio global JS library in TypeScript?

泪湿孤枕 提交于 2019-12-11 08:02:43
问题 I'm using Twilio.js library on my application (not Twilio Node) and there's no module nor typings for this library available. There's only a Twilio global variable available that one can use. The simplest ambient declaration one can have to avoid errors in the IDE is this: declare const Twilio: any; But I want to go a little bit further and for that I've been reading TypeScript handbook and few other resources. I've taken especially attention to this link. And here's what I have so far:

How to define a class in a source file and declare it in a header file (without having to define the class methods using `class::method` syntax)?

匆匆过客 提交于 2019-12-11 07:42:22
问题 I am looking at a library on github which has the following in one of the header files: class Util { public: static void log( const string& message ); static void log( const char* message ); template<typename T> static inline string toString(T t) { stringstream s; s << t; return s.str(); } }; and the following in the source file: void Util::log( const string& message ) { const string& logMessage = "[cppWebSockets] " + message; syslog( LOG_WARNING, "%s", logMessage.c_str( ) ); } void Util::log

What's the difference between these two enum declarations - C?

馋奶兔 提交于 2019-12-11 05:59:50
问题 I've started learning C and have reached the point of enums. An enum is basically a preferred alternative to DEFINE / const int , correct? What's the difference between these two declarations? #include <stdio.h> // method 1 enum days { Monday, Tuesday }; int main() { // method 1 enum days today; enum days tomorrow; today = Monday; tomorrow = Tuesday; if (today < tomorrow) printf("yes\n"); // method 2 enum {Monday, Tuesday} days; days = Tuesday; printf("%d\n", days); return 0; } 回答1: An

Is this proper C declaration? If so, why does it not work?

老子叫甜甜 提交于 2019-12-11 04:31:58
问题 I'm writing a demo program from an educational book made to teach "C" for Unix and Windows. However, sometimes I come across code that, when typed exactly, does not want to work. Eg. #include <stdio.h> int main() { /*This next line is the error */ int num = 2, bool = 0; if ( (num==2) && (!bool) ) { printf("The first test is untrue\n"); } else if( (num==2) && (!bool) ) { printf("The second test is true\n"); } else if( (num==2) && (bool==0) ) { printf("The third test is true - but unreached\n")

using declaration in header files

▼魔方 西西 提交于 2019-12-11 03:51:53
问题 I've been looking for some clarification for the usage of the using-declarations in header files (I was searching around but couldn't quite get the answer I'm looking for). What I my research concluded so far is, using them in the non-global scope is ok, while namespace directives are bad. That I understood (At least I hope so :)). So in my example I use shared_ptr s, but I need to support older compilers that do not have them in the std:: namespace but in std::tr1:: for example. Since every

Is `struct` keyword needed in declaring a variable of structure?

旧巷老猫 提交于 2019-12-11 02:28:01
问题 I have come to know from book that for declaring a structure variable it is necessary a preceding struct keyword, but without that preceding struct in my Bloodshed\DevC++ compiler variable can be declared without any error like following, struct stype { int ival; float fval; double dval; }; and in main, stype s; s.ival=10;s.dval=23.23;s.fval=233.23; printf("%d %f %lf\n",s.ival,s.fval,s.dval); This correctly prints what should be printed. Is there any modification behind using this struct

C++ nested constructor calls vs. function declaration

左心房为你撑大大i 提交于 2019-12-11 01:43:05
问题 What is the difference between the code snippets labeled "version 1" and "version 2" in the following code section: int main() { using namespace std; typedef istream_iterator<int> input; // version 1) //vector<int> v(input(cin), input()); // version 2) input endofinput; vector<int> v(input(cin), endofinput); } As far as I understand "version 1" is treated as function declaration. But I don't understand why nor what the arguments of the resulting function v with return type vector<int> are.

Declare symbols that remain valid outside their scope

只谈情不闲聊 提交于 2019-12-10 22:25:35
问题 Z3 2.x had the feature (well, probably rather the bug) that symbol declarations were not popped away, e.g. the following code is accepted by Z3 2.x: (push) (declare-fun x () Int) ; Assumptions made in this scope will be popped correctly (pop) (assert (= x x)) Z3 3.x no longer accepts this code ("unknown constant"). Is there a way to restore the old behaviour? Or another way how one could declare symbols inside scopes such that the declaration (and only the declaration, not the assumptions) is