class

C++ can't use class from another file

允我心安 提交于 2021-01-28 22:47:21
问题 I'm C++ by writing small programs. I'm too the point of working with multiple files. I'm stuck on using a class from another file. I made a simple test project to demonstrate my problem. I have 3 files. testheader.h #ifndef __testheader_H_INCLUDED__ // if Node.h hasn't been included yet... #define __testheader_H_INCLUDED__ // #define this so the compiler knows it has been included #include <string> #include <iostream> class testheader { public: testheader(std::string name){} void write(){} };

Conditional class in slim with 3 conditions

六月ゝ 毕业季﹏ 提交于 2021-01-28 22:17:43
问题 I would like to write conditional class in slim but I only know how to do it with 2 conditions, like : div class=(index == 0 ? 'class1' : 'class1 class3') How to do it with three conditions? - if index == 0 .class1 - elsif index == -1 .class2.class3 - else .class1.class3 回答1: div class=(if index == 0 then 'class1' elsif index == -1 then 'class2 class3' else '.class1 class3' end) 来源: https://stackoverflow.com/questions/40591084/conditional-class-in-slim-with-3-conditions

What does the error “Can't access this in a field initializer mean”?

眉间皱痕 提交于 2021-01-28 22:10:28
问题 I want to create a class in flutter for displaying an Alert Box, which can take in title and Content as input to show error box. But debug console says that "can't access this in a field initializer" when I used this to access a variable of the same class in AlertDialog(). import 'package:flutter/material.dart'; void main() => runApp(MaterialApp(home: Alert("Say Hy","Hy"),)); class Alert extends StatelessWidget{ final String titlea; final String contexta; Alert(this.titlea,this.contexta);

How do I call a class function inside the class definition?

一笑奈何 提交于 2021-01-28 21:29:53
问题 class MetaData(): maxSize = 2**10 # class definition code if not os.path.exists('sample.data'): SSD = open('sample.data', 'wb+') data = { 0: [], 1: {'.': None,} } data[1]['~'] = data[1] MetaData.save() # i want to call the save function here # class function @classmethod def save(cls): cls.SSD.seek(0) cls.SSD.write(b' ' * cls.maxSize) cls.SSD.seek(0) cls.SSD.write(pickle.dumps(cls.data)) I want to use the save() function inside the class block. I've tried MetaDate.save() and simply save()

Call activity from another project

我只是一个虾纸丫 提交于 2021-01-28 19:05:15
问题 i want call project A to project B, but in project B used project C for library. I used the code in project A intent = new Intent("com.example.projectb.reading"); startActivity(intent); and AndroidManifest in project B <activity android:name="com.example.projectb.reading" android:label="Trainee" android:screenOrientation="portrait"> <intent-filter> <action android:name="com.xample.projecta.cls_show" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>

Best place to store saved messages

柔情痞子 提交于 2021-01-28 18:55:24
问题 I am currently creating a console applications that only accepts some commands defined by me. The thing is I'm storing a lot of error and notification messages on a static class I created called Messages and then just calling them like Messages.ErrorMessage.... ErrorMessage is just a static string that contains w/e I want printed on the console. What I wanted to ask is if that's a good way of implementing such behavior or should I instead change where I'm keeping all of this Messages? Thanks

Python 3 binding not working

主宰稳场 提交于 2021-01-28 18:12:09
问题 Somehow only 2 of my bindings work(left and right mousebutton). I've done quite a few bindings in my previous programmes, but still, I have no idea why this doesn't work. Could somebody help me? class Window: def __init__(self): self.win=Tk() self.can=Canvas(self.win, height=800, width=800, bg="grey90") self.can.grid(row=0, column=0) class Player: def __init__(self, bind1, bind2): win.can.bind(bind1, self.moveleft) win.can.bind(bind2, self.moveright) def moveleft(event, self): print("left")

Why duck typing is allowed for classes in TypeScript

ぃ、小莉子 提交于 2021-01-28 14:09:56
问题 Looks like in TypeScript it's absolutely fine (from the compiler perspective) to have such code: class Vehicle { public run(): void { console.log('Vehicle.run'); } } class Task { public run(): void { console.log('Task.run'); } } function runTask(t: Task) { t.run(); } runTask(new Task()); runTask(new Vehicle()); But at the same time I would expect a compilation error , because Vehicle and Task don't have anything in common. And sane usages can be implemented via explicit interface definition:

Why @(NO) isn't kind of class NSNumber [closed]

三世轮回 提交于 2021-01-28 12:41:48
问题 Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Improve this question I have a weird behavior which seem due to some intern cooking in iOS. When I do : id data1 = @(NO); if ([data1 isKindOfClass:[NSNumber class]]) { // doesn't come here. } But with @(YES) it work perfectly. First I would like to understand why. Second, I would

Typescript | Call a function every time a function is called

自作多情 提交于 2021-01-28 11:09:59
问题 I am trying to write a Typescript API service. For the service I need a way to check that the method exists when a function such as get is called. I realise I can do like get(endpoint: string) { this.handleRequest(); } post(endpoint: string, data: any) { this.handleRequest(); } But I don't particularly want to do that are the top of every method so I didn't know if there was a way to listen within the constructor of the Typescript class for a call of a child function. It seems a little far