Re: Error: function declaration without return type.
On Wednesday, 7 January 2015 at 08:58:35 UTC, Suliman wrote: thanks! Am I right understand that in next code scope(exit) stmt.close(); occur after this execution? And it will close connection so stmt in function become unavailable. this(parseConfig parseconfig) { [] auto conn = ds.getConnection(); scope(exit) conn.close(); stmt = conn.createStatement(); scope(exit) stmt.close(); //HERE } void InsertData() { auto rs = stmt.executeUpdate(sqlinsert); // stmt now unreachable } scope(exit) executes at the exit of the inner most scope. Scopes end at '}'. Which is the very next line in this case.
Re: Error: function declaration without return type.
thanks! Am I right understand that in next code scope(exit) stmt.close(); occur after this execution? And it will close connection so stmt in function become unavailable. this(parseConfig parseconfig) { [] auto conn = ds.getConnection(); scope(exit) conn.close(); stmt = conn.createStatement(); scope(exit) stmt.close(); //HERE } void InsertData() { auto rs = stmt.executeUpdate(sqlinsert); // stmt now unreachable }
Re: Error: function declaration without return type.
On 01/06/2015 01:25 PM, Suliman wrote: On Tuesday, 6 January 2015 at 21:19:38 UTC, bearophile wrote: Suliman: void foo() { writeln(test); writeln(mystring); } foo(); } I guess you have to remove that line. Bye, bearophile Why? I can't call function in instance of class? Instances of classes are objects that are created by 'new'. So, yes, you can call member functions on instances of classes. There are two instances of Test in the following main(): import std.stdio; class Test { string mystring; this(string mystring) { this.mystring = mystring; } void foo() { writeln(test); writeln(mystring); } } void main() { auto a = new Test(hello); auto b = new Test(hi); a.foo(); b.foo(); } Ali
Re: Error: function declaration without return type.
On Tuesday, 6 January 2015 at 21:19:38 UTC, bearophile wrote: Suliman: void foo() { writeln(test); writeln(mystring); } foo(); } I guess you have to remove that line. Bye, bearophile Why? I can't call function in instance of class?
Re: Error: function declaration without return type.
Suliman: void foo() { writeln(test); writeln(mystring); } foo(); } I guess you have to remove that line. Bye, bearophile
Re: Error: function declaration without return type.
Dne 6.1.2015 v 22:25 Suliman via Digitalmars-d-learn napsal(a): On Tuesday, 6 January 2015 at 21:19:38 UTC, bearophile wrote: Suliman: void foo() { writeln(test); writeln(mystring); } foo(); } I guess you have to remove that line. Bye, bearophile Why? I can't call function in instance of class? What would that even mean? When would the function ran? If you want to call that function during instantiation, put it into constructor. If you want to call it sometime later, than you have to call it from somewhere else. But having a function call inside a class does not compute... Martin smime.p7s Description: Elektronicky podpis S/MIME
Re: Error: function declaration without return type.
On Tue, 06 Jan 2015 21:25:49 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 6 January 2015 at 21:19:38 UTC, bearophile wrote: Suliman: void foo() { writeln(test); writeln(mystring); } foo(); } I guess you have to remove that line. Bye, bearophile Why? I can't call function in instance of class? 'cause dlang specs (which you read with a great care, aren't you?) doesn't allow it. signature.asc Description: PGP signature